Advertisement
Guest User

Untitled

a guest
May 19th, 2017
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. <?php
  2. function registerform()
  3. {
  4. error_reporting(E_ALL);
  5. ini_set('display_errors','on');
  6.  
  7. echo "<h1>Registration Form:</h1>\n\n"; // Form name <h1>
  8. echo "<form name='registration' action='"; $php_self; echo "' method='post'>\n"; // Builds the html form
  9. echo "<table class='formtable'>"; // Starts the beggining of the table
  10.  
  11. if($_SERVER['REQUEST_METHOD'] == 'GET') {
  12. username("off");
  13. password("off");
  14. }
  15. elseif($_SERVER['REQUEST_METHOD'] == 'POST') {
  16. username("on");
  17. password("on");
  18. }
  19.  
  20. echo "<tr>\n<td>\n</td>\n";
  21. echo "<td><input type='submit' value='Register'> <input type='reset' value='Reset'></td>\n</tr>\n</table></form>";
  22. // Creates submit button and reset button, and also closes the form and table tabs
  23.  
  24. }
  25.  
  26. function username($status) {
  27. echo "<tr>\n";
  28. echo "<td>Username:</p></td>\n";
  29. echo "<td><input type='text' name='username' value=''>";
  30. if($status == "on") { checkform("usercheck"); } else {}
  31. echo "</td>\n</tr>\n";
  32. }
  33.  
  34. function password($status2) {
  35. echo "<tr>\n";
  36. echo "<td>Password:</p></td>\n";
  37. echo "<td><input type='password' name='password1'></td>\n";
  38. echo "</tr>\n";
  39. echo "<tr>\n";
  40. echo "<td>Re-Type Password:</p></td>\n";
  41. echo "<td><input type='password' name='password2'>";
  42. if($status2 == "on") { checkform("passcheck"); } else {}
  43. echo "</td>\n</tr>\n";
  44. }
  45.  
  46. function checkform($checktype){
  47.  
  48. switch($checktype)
  49. {
  50. case "usercheck" :
  51. $username = $_POST['username'];
  52. if(!(isset($username) && (strlen($username) > 2) && (strlen($username) < 20) && (ctype_alpha($username)))) {
  53. $errors['username'] = '<br>Username needs to be over 2 letters long and can only contain the letters A-Z';
  54. echo $errors['username'];
  55. }
  56. break;
  57.  
  58. case "passcheck" :
  59.  
  60. $pass1 = $_POST['password1']; // Get password1 submitted from form
  61. $pass2 = $_POST['password2']; // Get password2 submitted from form
  62.  
  63. if($pass1 == $pass2)
  64. {
  65. if(!(isset($pass1) && (strlen($pass1) > 2) && (strlen($pass1) < 20) && (ctype_alpha($pass1))))
  66. {
  67. $errors['password'] = '<br>Password needs to be over 2 letters long and can only contain the letters A-Z';
  68. //echo $errors['password'];
  69. }
  70. else {
  71. $errors['password'] = '<br>Passwords Match!';
  72. }
  73. }
  74. else
  75. {
  76. $errors['password'] = '<br>Passwords Did not Match!';
  77. //echo $errors['password'];
  78. }
  79.  
  80. echo $errors['password'];
  81.  
  82. break;
  83.  
  84. }
  85. }
  86.  
  87. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement