Advertisement
Guest User

Untitled

a guest
May 19th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. <?php
  2. function registerform()
  3. {
  4.  
  5. error_reporting(E_ALL);
  6. ini_set('display_errors','on');
  7.  
  8. echo "<h1>Registration Form:</h1>\n\n"; // Form name <h1>
  9. echo "<form name='registration' action='"; $php_self; echo "' method='post'>\n"; // Builds the html form
  10. echo "<table class='formtable'>"; // Starts the beggining of the table
  11.  
  12. username(); // Calls the username function creating part of the table
  13. //password(); // Calls the password function creating part of the table
  14. //firstname(); // Calls the firstname function creating part of the table
  15. //lastname(); // Calls the lastname function creating part of the table//
  16. //dateofbirth(); // Calls the d.o.b function creating part of the table
  17. //email(); // Calls the email function creating part of the table
  18. //gender(); // Calls the gender function creating part of the table
  19. //question(); // Calls the question function creating part of the table
  20.  
  21. echo "<tr>\n<td>\n</td>\n";
  22. echo "<td><input type='submit' value='Register'> <input type='reset' value='Reset'></td>\n</tr>\n</table></form>";
  23. // Creates submit button and reset button, and also closes the form and table tabs
  24. }
  25.  
  26. function username() {
  27. if($_SERVER['REQUEST_METHOD'] == 'GET') {
  28. echo "<tr>\n";
  29. echo "<td>Username:</p></td>\n";
  30. echo "<td><input type='text' name='username' value=''>";
  31. }
  32. elseif($_SERVER['REQUEST_METHOD'] == 'POST') {
  33. $username = $_POST['username'];
  34. if(!(isset($username) && (strlen($username) > 2) && (strlen($username) < 20) && (ctype_alpha($username)))) {
  35. echo "<tr>\n";
  36. echo "<td>Username:</p></td>\n";
  37. echo "<td><input type='text' name='username' value=''>";
  38. echo "<br>Username needs to be over 2 letters long and can only contain the letters A-Z'";
  39. }
  40. else {
  41. $_POST['username'];
  42. }
  43. }
  44. }
  45.  
  46. function password() {
  47.  
  48. $pass1 = $_GET['password1']; // Get password1 submitted from form
  49. $pass2 = $_GET['password2']; // Get password2 submitted from form
  50.  
  51. echo "<tr>\n";
  52. echo "<td>Password:</p></td>\n";
  53. echo "<td><input type='password' name='password1'></td>\n";
  54. echo "</tr>\n";
  55. echo "<tr>\n";
  56. echo "<td>Re-Type Password:</p></td>\n";
  57. echo "<td><input type='password' name='password2'>\n";
  58.  
  59. echo "</td>\n</tr>\n";
  60. }
  61.  
  62. function firstname() {
  63.  
  64. $fname = $_GET['firstname']; // Get firstname submitted from form
  65.  
  66. echo "<tr>\n";
  67. echo "<td>First Name:</p></td>\n";
  68. echo "<td><input type='text' name='firstname' value='" . $fname . "'>\n";
  69.  
  70. echo "</td>\n</tr>\n";
  71. }
  72.  
  73. function lastname() {
  74.  
  75. $sname = $_GET['secondname']; // Get lastname submitted from form
  76.  
  77. echo "<tr>\n";
  78. echo "<td>Second Name:</p></td>\n";
  79. echo "<td><input type='text' name='secondname' value='" . $sname . "'>\n";
  80.  
  81. echo "</td>\n</tr>\n";
  82. }
  83.  
  84. function dateofbirth() {
  85. echo "<tr>\n";
  86. echo "<td>Date of birth:\n</p></td>\n";
  87. echo "<td valign='top'>"; include("dob.php"); days(); echo " / "; month(); echo " / "; year();
  88. echo "</td>\n</tr>\n";
  89. }
  90.  
  91. function email() {
  92.  
  93. $email = $_GET['email']; // Get email address submitted from form
  94.  
  95. echo "<tr>\n";
  96. echo "<td>Current Email:</p></td>\n";
  97. echo "<td><input type='text' name='email' size='25' value='" . $email . "'>\n";
  98.  
  99. echo "</td>\n</tr>\n";
  100. }
  101.  
  102. function gender() {
  103.  
  104. echo "<tr>\n";
  105. echo "<td>Gender:</p></td>\n";
  106. echo "<td><select name='gender'>
  107. <option value='Male'>Male</option>
  108. <option value='Female'>Female</option
  109. </select>";
  110. echo "</td>\n</tr>\n";
  111. }
  112.  
  113. function question() {
  114.  
  115. $answer = $_GET['answer']; // Get answer submitted from form
  116.  
  117. echo "<tr>\n";
  118. echo "<td>Secret Question:</p></td>\n";
  119. echo "<td><select name='question'>
  120. <option value='Favourite Pets Name?'>Favourite Pets Name</option>
  121. <option value='Name of School?'>Name of School</option>
  122. <option value='Place of birth?'>Place of Birth</option>
  123. <option value='Mothers Maiden Name?'>Mothers Maiden Name</option>
  124. </select>
  125. </td>";
  126. echo "</tr>\n";
  127. echo "<tr>\n";
  128. echo "<td>Secret Answer:</p></td>\n";
  129. echo "<td><input type='text' name='answer' size='25' value='" . $answer . "'>\n";
  130. echo "</td>\n</tr>\n";
  131. }
  132.  
  133. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement