Advertisement
Guest User

Untitled

a guest
Nov 9th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.36 KB | None | 0 0
  1. <?php
  2. function displayRegister(){
  3. if(isset($_POST['submitRegister'])){
  4. sendRegisterForm();
  5. }
  6.  
  7.  
  8. $usernameErr = $emailErr = $firstErr = $lastErr = $zipErr = $cityErr = $streetErr = "";
  9. $username = $email = $pass = $first = $last = $zip = $city = $street = "";
  10.  
  11.  
  12. ?>
  13.  
  14.  
  15. <form method="post" autocomplete="on" id="register">
  16. <h1> Sign up </h1>
  17. <table>
  18.  
  19.  
  20. <tr>
  21. <td>
  22. <label for="usernamesignup" class="label" data-icon="u">Username</label>
  23. </td>
  24. <td>
  25. <input id="usernamesignup" class="input" name="usernamesignup" required="required" type="text" placeholder="Username" />
  26. <php
  27. if (empty($_POST["usernamesignup"])) {
  28. $usernameErr = "First Name is required";
  29. echo $usernameErr;
  30. } else {
  31. $username = test_input($_POST["usernamesignup"]);
  32. // check if username contains only whitespace, numbers and underline
  33. if (!preg_match("/^[a-zA-Z0-9]*_?[a-zA-Z0-9]*$/",$username)) {
  34. $usernameErr = "Only letters,numbers and underline allowed";
  35.  
  36. }
  37.  
  38. ?>
  39.  
  40.  
  41. </td>
  42. </tr>
  43. <tr>
  44. <td><label for="emailsignup" class="label" data-icon="e" >E-mail</label></td>
  45. <td><input id="emailsignup" class="input" name="emailsignup" required="required" type="email" placeholder="example@mail.com"/></td>
  46.  
  47. </tr>
  48. <tr>
  49. <td><label for="passwordsignup" class="label" data-icon="p">Your password</label></td>
  50. <td><input id="passwordsignup" class="input" name="passwordsignup" required="required" type="password" placeholder="Password"/></td>
  51. <php
  52. if (empty($_POST["passwordsignup"])) {
  53. $passErr = "password is required";
  54. } else {
  55. $pass = test_input($_POST["passwordsignup"]);
  56. // password needs atleast one letter, one number and needs to be at least 8 characters and max 12 characters
  57. if (!preg_match("/^[a-zA-Z ]*$/",$pass)) {
  58. $passErr = "Password needs atleast one letter, one number and needs to be at least 8 characters and max 12 characters";
  59. }
  60. ?>
  61. </tr>
  62. <tr>
  63. <td><label for="passwordsignup_confirm" class="label" data-icon="p">Please confirm your password</label></td>
  64. <td><input id="passwordsignup_confirm" class="input" name="passwordsignup_confirm" required="required" type="password" placeholder="Password"/></td>
  65. <php
  66. if ($_POST["passwordsignup"]==$_POST["passwordsignup_confirm"]){
  67. $passwordsucces="";}
  68. else{
  69. $passwordfailed="Password is not the same as the first input"}
  70.  
  71.  
  72.  
  73.  
  74.  
  75. ?>
  76. </tr>
  77. <tr>
  78. <td><label for="firstnamesignup" class="label" data-icon="u">First name</label></td>
  79. <td><input id="firstnamesignup" class="input" name="firstnamesignup" required="required" type="text" placeholder="First name" /></td>
  80. <php
  81. if (empty($_POST["firstnamesignup"])) {
  82. $firstErr = "First Name is required";
  83. } else {
  84. $first = test_input($_POST["firstnamesignup"]);
  85. // check if name only contains letters and whitespace
  86. if (!preg_match("/^[a-zA-Z ]*$/",$first)) {
  87. $firstErr = "Only letters and white space allowed";
  88. }
  89. ?>
  90. </tr>
  91. <tr>
  92. <td><label for="lastnamesignup" class="label" data-icon="u">Last name</label></td>
  93. <td><input id="lastnamesignup" class="input" name="lastnamesignup" required="required" type="text" placeholder="Last name" /></td>
  94. <php
  95. if (empty($_POST["lastnamesignup"])) {
  96. $lastErr = "Last Name is required";
  97. } else {
  98. $last = test_input($_POST["lastnamesignup"]);
  99. // check if name only contains letters and whitespace
  100. if (!preg_match("/^[a-zA-Z ]*$/",$last)) {
  101. $lastErr = "Only letters and white space allowed";
  102. }
  103. ?>
  104.  
  105. </tr>
  106. <tr>
  107. <td><label for="phonesignup" class="label" data-icon="u">Phone number</label></td>
  108. <td><input id="phonesignup" class="input" name="phonesignup" type="number" placeholder="0123456789" /></td>
  109.  
  110.  
  111.  
  112. </tr>
  113.  
  114. <tr>
  115. <td><label for="streetsignup" class="label" data-icon="u">Street</label></td>
  116. <td><input id="streetsignup" class="input" name="streetsignup" required="required" type="text" placeholder="Street" /></td>
  117. <php
  118. if (empty($_POST["streetnumbersignup"])) {
  119. $streetErr = "streetname is required";
  120. } else {
  121. $street = test_input($_POST["streetnumbersignup"]);
  122. // check if name only contains letters and whitespace
  123. if (!preg_match("/^[a-zA-Z ]*$/",$street)) {
  124. $streetErr = "only letters and whitespace allowed";
  125. }
  126. ?>
  127.  
  128. </tr>
  129. <tr>
  130. <td><label for="streetnumbersignup" class="label" data-icon="u">Street number</label></td>
  131. <td><input id="streetnumbersignup" class="input" name="streetnumbersignup" required="required" type="number" placeholder="Streetnumber" /></td>
  132.  
  133. </tr>
  134. <tr>
  135. <td><label for="additionsignup" class="label" data-icon="u">Addition</label></td>
  136. <td><input id="additionsignup" class="input" name="additionsignup" type="text" placeholder="Addition" /></td>
  137.  
  138. </tr>
  139. <tr>
  140. <td><label for="zipcodesignup" class="label" data-icon="u">Zipcode</label></td>
  141. <td><input id="zipcodesignup" class="input" name="zipcodesignup" required="required" type="text" placeholder="1234AB" /></td>
  142. <php
  143. if (empty($_POST["zipcodesignup"])) {
  144. $zipErr = "zipcode is required";
  145. } else {
  146. $zip = test_input($_POST["zipcodesignup"]);
  147.  
  148. if (!preg_match("/^[0-9]{4}\s[A-Z]{2}$/",$zip)) {
  149. $zipErr = "Error zip code needs to be like 9999 AA";
  150. }
  151. ?>
  152. </tr>
  153. <tr>
  154. <td><label for="citysignup" class="label" data-icon="u">City</label></td>
  155. <td><input id="citysignup" class="input" name="citysignup" required="required" type="text" placeholder="City" /></td>
  156. <php
  157. if (empty($_POST["citysignup"])) {
  158. $cityErr = "cityname is required";
  159. } else {
  160. $city = test_input($_POST["citysignup"]);
  161. // check if name only contains letters and whitespace
  162. if (!preg_match("/^[a-zA-Z ]*$/",$city)) {
  163. $cityErr = "only letters and whitespace allowed";
  164. }
  165. ?>
  166. </tr>
  167. <tr>
  168. <td><input type="submit" value="Sign up" name="submitRegister" class="button"/></td>
  169. </tr>
  170. </table>
  171. </form>
  172.  
  173.  
  174. <?php } ?>
  175.  
  176. <php
  177. echo $username;
  178. echo $email;
  179. echo $pass;
  180. echo $first;
  181. echo $last;
  182. echo $zip;
  183. echo $city;
  184. echo $street;
  185. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement