Advertisement
Guest User

Untitled

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