SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | function displayRegister(){ | |
3 | ||
4 | $usernameErr = $passErr = $passwordfailed = $emailErr = $firstErr = $lastErr = $zipErr = $cityErr = $streetErr = ""; | |
5 | - | $usernameErr = $emailErr = $firstErr = $lastErr = $zipErr = $cityErr = $streetErr = ""; |
5 | + | $username = $email = $pass = $first = $last = $zip = $city = $street = ""; |
6 | - | $username = $email = $pass = $first = $last = $zip = $city = $street = ""; |
6 | + | |
7 | if (isset($_POST['submitRegister'])) { | |
8 | $username = ($_POST["usernamesignup"]); | |
9 | // check if username contains only whitespace, numbers and underline | |
10 | if (!preg_match("/^[a-zA-Z0-9]*_?[a-zA-Z0-9]*$/", $username)) { | |
11 | $usernameErr = "Only letters,numbers and underline allowed"; | |
12 | } | |
13 | - | if ($_SERVER["REQUEST_METHOD"] == "POST"){ |
13 | + | |
14 | - | $username = ($_POST["usernamesignup"]); |
14 | + | $pass = ($_POST["passwordsignup"]); |
15 | - | // check if username contains only whitespace, numbers and underline |
15 | + | // password needs atleast one letter, one number and needs to be at least 8 characters and max 12 characters |
16 | - | if (!preg_match("/^[a-zA-Z0-9]*_?[a-zA-Z0-9]*$/", $username)) { |
16 | + | if (!preg_match("/^(?=.*\d)(?=.*[A-Za-z])[0-9A-Za-z!@#$%]{8,12}$/", $pass)) { |
17 | - | $usernameErr = "Only letters,numbers and underline allowed"; |
17 | + | $passErr = "Password needs atleast one letter, one number and needs to be at least 8 characters and max 12 characters"; |
18 | } | |
19 | - | } |
19 | + | |
20 | if ($_POST["passwordsignup"] != $_POST["passwordsignup_confirm"]){ | |
21 | - | $pass = ($_POST["passwordsignup"]); |
21 | + | $passwordfailed = "Password is not the same as the first input"; |
22 | - | // password needs atleast one letter, one number and needs to be at least 8 characters and max 12 characters |
22 | + | } |
23 | - | if (!preg_match("/^(?=.*\d)(?=.*[A-Za-z])[0-9A-Za-z!@#$%]{8,12}$/", $pass)) { |
23 | + | |
24 | - | $passErr = "Password needs atleast one letter, one number and needs to be at least 8 characters and max 12 characters"; |
24 | + | $first = ($_POST["firstnamesignup"]); |
25 | - | } |
25 | + | // check if name only contains letters and whitespace |
26 | if (!preg_match("/^[a-zA-Z ]*$/", $first)) { | |
27 | - | if ($_POST["passwordsignup"]==$_POST["passwordsignup_confirm"]){ |
27 | + | $firstErr = "Only letters and white space allowed"; |
28 | - | $passwordfailed="";} |
28 | + | } |
29 | - | else{ |
29 | + | |
30 | - | $passwordfailed="Password is not the same as the first input"; } |
30 | + | $last = ($_POST["lastnamesignup"]); |
31 | // check if name only contains letters and whitespace | |
32 | - | $first = ($_POST["firstnamesignup"]); |
32 | + | if (!preg_match("/^[a-zA-Z ]*$/", $last)) { |
33 | - | // check if name only contains letters and whitespace |
33 | + | $lastErr = "Only letters and white space allowed"; |
34 | - | if (!preg_match("/^[a-zA-Z ]*$/", $first)) { |
34 | + | } |
35 | - | $firstErr = "Only letters and white space allowed"; |
35 | + | |
36 | - | } |
36 | + | $street = ($_POST["streetsignup"]); |
37 | // check if name only contains letters and whitespace | |
38 | - | $last = ($_POST["lastnamesignup"]); |
38 | + | if (!preg_match("/^[a-zA-Z ]*$/", $street)) { |
39 | - | // check if name only contains letters and whitespace |
39 | + | $streetErr = "only letters and whitespace allowed"; |
40 | - | if (!preg_match("/^[a-zA-Z ]*$/", $last)) { |
40 | + | } |
41 | - | $lastErr = "Only letters and white space allowed"; |
41 | + | |
42 | - | } |
42 | + | $zip = ($_POST["zipcodesignup"]); |
43 | if (!preg_match("/^[0-9]{4}\s[A-Z]{2}$/", $zip)) { | |
44 | - | $street = ($_POST["streetsignup"]); |
44 | + | $zipErr = "Error zip code needs to be like 9999 AA"; |
45 | - | // check if name only contains letters and whitespace |
45 | + | } |
46 | - | if (!preg_match("/^[a-zA-Z ]*$/", $street)) { |
46 | + | |
47 | - | $streetErr = "only letters and whitespace allowed"; |
47 | + | $city = ($_POST["citysignup"]); |
48 | // check if name only contains letters and whitespace | |
49 | - | } |
49 | + | if (!preg_match("/^[a-zA-Z ]*$/", $city)) { |
50 | $cityErr = "only letters and whitespace allowed"; | |
51 | - | $zip = ($_POST["zipcodesignup"]); |
51 | + | |
52 | } | |
53 | - | if (!preg_match("/^[0-9]{4}\s[A-Z]{2}$/", $zip)) { |
53 | + | |
54 | - | $zipErr = "Error zip code needs to be like 9999 AA"; |
54 | + | } |
55 | - | } |
55 | + | if (empty($usernameErr & $passErr & $passwordfailed & $firstErr & $lastErr & $streetErr & $zipErr & $cityErr)){ |
56 | sendRegisterForm(); | |
57 | - | $city = ($_POST["citysignup"]); |
57 | + | }else{ |
58 | - | // check if name only contains letters and whitespace |
58 | + | echo $usernameErr . "</br>" . $passErr; |
59 | - | if (!preg_match("/^[a-zA-Z ]*$/", $city)) { |
59 | + | } ?> |
60 | - | $cityErr = "only letters and whitespace allowed"; |
60 | + | |
61 | <table class="registrationForm"> | |
62 | - | } |
62 | + | <caption>Registration</caption> |
63 | <tr> | |
64 | - | } |
64 | + | <td> |
65 | <label for="usernamesignup" class="label" data-icon="u">Username</label> | |
66 | - | function displayRegister() |
66 | + | </td> |
67 | - | { |
67 | + | <td> |
68 | <input id="usernamesignup" class="input" name="usernamesignup" required="required" type="text" placeholder="Username" /> | |
69 | - | if (isset($_POST['submitRegister'])) { |
69 | + | </td> |
70 | - | if (isset($usernameErr,$passErr,$passwordfailed,$firstErr,$lastErr,$streetErr,$zipErr,$cityErr)){ |
70 | + | </tr> |
71 | <tr> | |
72 | - | ;} |
72 | + | <td><label for="emailsignup" class="label" data-icon="e" >E-mail</label></td> |
73 | - | else{ |
73 | + | <td><input id="emailsignup" class="input" name="emailsignup" required="required" type="email" placeholder="example@mail.com"/></td> |
74 | - | sendRegisterForm();} |
74 | + | </tr> |
75 | <tr> | |
76 | - | } |
76 | + | <td><label for="passwordsignup" class="label" data-icon="p">Your password</label></td> |
77 | <td><input id="passwordsignup" class="input" name="passwordsignup" required="required" type="password" placeholder="Password"/></td> | |
78 | </tr> | |
79 | <tr> | |
80 | - | ?> |
80 | + | <td><label for="passwordsignup_confirm" class="label" data-icon="p">Please confirm your password</label></td> |
81 | <td><input id="passwordsignup_confirm" class="input" name="passwordsignup_confirm" required="required" type="password" placeholder="Password"/></td> | |
82 | </tr> | |
83 | <tr> | |
84 | - | <h1> Sign up </h1> |
84 | + | <td><label for="firstnamesignup" class="label" data-icon="u">First name</label></td> |
85 | - | <table> |
85 | + | <td><input id="firstnamesignup" class="input" name="firstnamesignup" required="required" type="text" placeholder="First name" /></td> |
86 | </tr> | |
87 | <tr> | |
88 | <td><label for="lastnamesignup" class="label" data-icon="u">Last name</label></td> | |
89 | - | <tr> |
89 | + | <td><input id="lastnamesignup" class="input" name="lastnamesignup" required="required" type="text" placeholder="Last name" /></td> |
90 | - | <td> |
90 | + | </tr> |
91 | - | <label for="usernamesignup" class="label" data-icon="u">Username</label> |
91 | + | <tr> |
92 | - | </td> |
92 | + | <td><label for="phonesignup" class="label" data-icon="u">Phone number</label></td> |
93 | - | <td> |
93 | + | <td><input id="phonesignup" class="input" name="phonesignup" type="text" placeholder="0123456789" /></td> |
94 | - | <input id="usernamesignup" class="input" name="usernamesignup" required="required" type="text" |
94 | + | </tr> |
95 | - | placeholder="Username"/> |
95 | + | <tr> |
96 | <td><label for="streetsignup" class="label" data-icon="u">Street</label></td> | |
97 | <td><input id="streetsignup" class="input" name="streetsignup" required="required" type="text" placeholder="Street" /></td> | |
98 | </tr> | |
99 | <tr> | |
100 | - | </td> |
100 | + | <td><label for="streetnumbersignup" class="label" data-icon="u">Street number</label></td> |
101 | - | </tr> |
101 | + | <td><input id="streetnumbersignup" class="input" name="streetnumbersignup" required="required" type="text" placeholder="Streetnumber" /></td> |
102 | - | <tr> |
102 | + | </tr> |
103 | - | <td><label for="emailsignup" class="label" data-icon="e">E-mail</label></td> |
103 | + | <tr> |
104 | - | <td><input id="emailsignup" class="input" name="emailsignup" required="required" type="email" |
104 | + | <td><label for="additionsignup" class="label" data-icon="u">Addition</label></td> |
105 | - | placeholder="example@mail.com"/></td> |
105 | + | <td><input id="additionsignup" class="input" name="additionsignup" type="text" placeholder="Addition" /></td> |
106 | </tr> | |
107 | - | </tr> |
107 | + | <tr> |
108 | - | <tr> |
108 | + | <td><label for="zipcodesignup" class="label" data-icon="u">Zipcode</label></td> |
109 | - | <td><label for="passwordsignup" class="label" data-icon="p">Your password</label></td> |
109 | + | <td><input id="zipcodesignup" class="input" name="zipcodesignup" required="required" type="text" placeholder="1234AB" /></td> |
110 | - | <td><input id="passwordsignup" class="input" name="passwordsignup" required="required" type="password" |
110 | + | </tr> |
111 | - | placeholder="Password"/></td> |
111 | + | <tr> |
112 | <td><label for="citysignup" class="label" data-icon="u">City</label></td> | |
113 | - | </tr> |
113 | + | <td><input id="citysignup" class="input" name="citysignup" required="required" type="text" placeholder="City" /></td> |
114 | - | <tr> |
114 | + | </tr> |
115 | - | <td><label for="passwordsignup_confirm" class="label" data-icon="p">Please confirm your password</label> |
115 | + | <tr> |
116 | - | </td> |
116 | + | <td></td> |
117 | - | <td><input id="passwordsignup_confirm" class="input" name="passwordsignup_confirm" required="required" |
117 | + | <td><input type="submit" value="Sign up" name="submitRegister" class="button button-right"/></td> |
118 | - | type="password" placeholder="Password"/></td> |
118 | + | </tr> |
119 | </table> | |
120 | - | </tr> |
120 | + | </form> |
121 | - | <tr> |
121 | + | |
122 | - | <td><label for="firstnamesignup" class="label" data-icon="u">First name</label></td> |
122 | + | |
123 | - | <td><input id="firstnamesignup" class="input" name="firstnamesignup" required="required" type="text" |
123 | + | <?php } ?> |