Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function displayRegister(){
- if(isset($_POST['submitRegister'])){
- sendRegisterForm();
- }
- $usernameErr = $emailErr = $firstErr = $lastErr = $zipErr = $cityErr = $streetErr = "";
- $username = $email = $pass = $first = $last = $zip = $city = $street = "";
- ?>
- <form method="post" autocomplete="on" id="register">
- <h1> Sign up </h1>
- <table>
- <tr>
- <td>
- <label for="usernamesignup" class="label" data-icon="u">Username</label>
- </td>
- <td>
- <input id="usernamesignup" class="input" name="usernamesignup" required="required" type="text" placeholder="Username" />
- <?php
- if (empty($_POST["usernamesignup"])) {
- $usernameErr = "First Name is required";
- echo $usernameErr;
- } else {
- $username = test_input($_POST["usernamesignup"]);
- // check if username contains only whitespace, numbers and underline
- if (!preg_match("/^[a-zA-Z0-9]*_?[a-zA-Z0-9]*$/", $username)) {
- $usernameErr = "Only letters,numbers and underline allowed";
- }
- }
- ?>
- </td>
- </tr>
- <tr>
- <td><label for="emailsignup" class="label" data-icon="e" >E-mail</label></td>
- <td><input id="emailsignup" class="input" name="emailsignup" required="required" type="email" placeholder="example@mail.com"/></td>
- </tr>
- <tr>
- <td><label for="passwordsignup" class="label" data-icon="p">Your password</label></td>
- <td><input id="passwordsignup" class="input" name="passwordsignup" required="required" type="password" placeholder="Password"/></td>
- <?php
- if (empty($_POST["passwordsignup"])) {
- $passErr = "password is required";
- } else {
- $pass = test_input($_POST["passwordsignup"]);
- // password needs atleast one letter, one number and needs to be at least 8 characters and max 12 characters
- if (!preg_match("/^[a-zA-Z ]*$/", $pass)) {
- $passErr = "Password needs atleast one letter, one number and needs to be at least 8 characters and max 12 characters";
- }
- }
- ?>
- </tr>
- <tr>
- <td><label for="passwordsignup_confirm" class="label" data-icon="p">Please confirm your password</label></td>
- <td><input id="passwordsignup_confirm" class="input" name="passwordsignup_confirm" required="required" type="password" placeholder="Password"/></td>
- <?php
- if ($_POST["passwordsignup"]==$_POST["passwordsignup_confirm"]){
- $passwordsucces="";}
- else{
- $passwordfailed="Password is not the same as the first input"; }
- ?>
- </tr>
- <tr>
- <td><label for="firstnamesignup" class="label" data-icon="u">First name</label></td>
- <td><input id="firstnamesignup" class="input" name="firstnamesignup" required="required" type="text" placeholder="First name" /></td>
- <?php
- if (empty($_POST["firstnamesignup"])) {
- $firstErr = "First Name is required";
- } else {
- $first = test_input($_POST["firstnamesignup"]);
- // check if name only contains letters and whitespace
- if (!preg_match("/^[a-zA-Z ]*$/", $first)) {
- $firstErr = "Only letters and white space allowed";
- }
- }
- ?>
- </tr>
- <tr>
- <td><label for="lastnamesignup" class="label" data-icon="u">Last name</label></td>
- <td><input id="lastnamesignup" class="input" name="lastnamesignup" required="required" type="text" placeholder="Last name" /></td>
- <?php
- if (empty($_POST["lastnamesignup"])) {
- $lastErr = "Last Name is required";
- } else {
- $last = test_input($_POST["lastnamesignup"]);
- // check if name only contains letters and whitespace
- if (!preg_match("/^[a-zA-Z ]*$/", $last)) {
- $lastErr = "Only letters and white space allowed";
- }
- }
- ?>
- </tr>
- <tr>
- <td><label for="phonesignup" class="label" data-icon="u">Phone number</label></td>
- <td><input id="phonesignup" class="input" name="phonesignup" type="number" placeholder="0123456789" /></td>
- </tr>
- <tr>
- <td><label for="streetsignup" class="label" data-icon="u">Street</label></td>
- <td><input id="streetsignup" class="input" name="streetsignup" required="required" type="text" placeholder="Street" /></td>
- <?php
- if (empty($_POST["streetnumbersignup"])) {
- $streetErr = "streetname is required";
- } else {
- $street = test_input($_POST["streetnumbersignup"]);
- // check if name only contains letters and whitespace
- if (!preg_match("/^[a-zA-Z ]*$/", $street)) {
- $streetErr = "only letters and whitespace allowed";
- }
- }
- ?>
- </tr>
- <tr>
- <td><label for="streetnumbersignup" class="label" data-icon="u">Street number</label></td>
- <td><input id="streetnumbersignup" class="input" name="streetnumbersignup" required="required" type="number" placeholder="Streetnumber" /></td>
- </tr>
- <tr>
- <td><label for="additionsignup" class="label" data-icon="u">Addition</label></td>
- <td><input id="additionsignup" class="input" name="additionsignup" type="text" placeholder="Addition" /></td>
- </tr>
- <tr>
- <td><label for="zipcodesignup" class="label" data-icon="u">Zipcode</label></td>
- <td><input id="zipcodesignup" class="input" name="zipcodesignup" required="required" type="text" placeholder="1234AB" /></td>
- <?php
- if (empty($_POST["zipcodesignup"])) {
- $zipErr = "zipcode is required";
- } else {
- $zip = test_input($_POST["zipcodesignup"]);
- if (!preg_match("/^[0-9]{4}\s[A-Z]{2}$/", $zip)) {
- $zipErr = "Error zip code needs to be like 9999 AA";
- }
- }
- ?>
- </tr>
- <tr>
- <td><label for="citysignup" class="label" data-icon="u">City</label></td>
- <td><input id="citysignup" class="input" name="citysignup" required="required" type="text" placeholder="City" /></td>
- <?php
- if (empty($_POST["citysignup"])) {
- $cityErr = "cityname is required";
- } else {
- $city = test_input($_POST["citysignup"]);
- // check if name only contains letters and whitespace
- if (!preg_match("/^[a-zA-Z ]*$/", $city)) {
- $cityErr = "only letters and whitespace allowed";
- }
- }
- ?>
- </tr>
- <tr>
- <td><input type="submit" value="Sign up" name="submitRegister" class="button"/></td>
- </tr>
- </table>
- </form>
- <?php echo $username;
- echo $email;
- echo $pass;
- echo $first;
- echo $last;
- echo $zip;
- echo $city;
- echo $street; } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement