Fout afhandeling registratie formulier werkt niet.
Ik ben bezig met een login/registratie formulier. Het is een bestaand script maar er was bijna geen controle op de invoer.
Hiervoor heb ik een ander script gebruikt. Aan de voorkant gaat alles goed ook de controle of het ingevoerde email adres al bestaat.
Maar aan de achterkant werkt het niet. De velden die zijn ingevuld of ze nou fout of goed zijn die worden gelijk ingevoerd in de database. Ik zelf denk dat het met het aller laatste stukje code te maken heeft.
Dit is het registratie formulier met de toegevoegde controle:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<?php
require 'db_connect.php';
session_start();
ini_set( 'display_errors', true );
error_reporting( E_ALL | E_STRICT );
// E-mail Checker / Validator.
function checkmail($email)
{
if (preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i", $email))
{
list($userName, $mailDomain) = split("@", $email);
if (checkdnsrr($mailDomain, "MX")) {
return TRUE;
}
}
return FALSE;
}
$formulier = TRUE;
if(isset($_POST['register']) && ($_SERVER['REQUEST_METHOD'] == "POST"))
{
$aFout = array();
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$password = $_POST['password'];
if(TRUE)
{
$code = $_POST['code'];
}
// Als $firstname leeg is of $voonaam minder dan 2 tekens bevat of deze bepaalde tekens bevat preg_match) dan word de uitvoer Fout. (||=of)(&&=AND).
if(empty($firstname) || (strlen($firstname) < 2) || preg_match("[<>]", $firstname) )
{
$aFout[] = "Er is geen firstname ingevuld.";
unset($firstname);
$fout['text']['firstname'] = TRUE;
$fout['input']['firstname'] = TRUE;
}
// Als $lastname leeg is of $lastname minder dan 2 tekens bevat of deze bepaalde tekens bevat preg_match) dan word de uitvoer Fout. (||=of)(&&=AND).
if(empty($lastname) || (strlen($lastname) < 2) || preg_match("[<>]", $lastname) )
{
$aFout[] = "Er is geen lastname ingevuld.";
unset($lastname);
$fout['text']['lastname'] = TRUE;
$fout['input']['lastname'] = TRUE;
}
if(empty($email))
{
$aFout[] = "Er is geen e-mail adres ingevuld.";
unset($email);
$fout['text']['email'] = TRUE;
$fout['input']['email'] = TRUE;
}
elseif(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
$aFout[] = "Er is geen correct e-mail adres ingevuld.";
unset($email);
$fout['text']['email'] = TRUE;
$fout['input']['email'] = TRUE;
}
if(empty($password))
{
$aFout[] = "Er is geen password ingevuld.";
unset($password);
$fout['text']['password'] = TRUE;
$fout['input']['password'] = TRUE;
}
if(TRUE)
{
if(strtoupper($code) != $_SESSION['captcha_code'])
{
$aFout[] = "Er is geen correcte code ingevuld.";
$fout['text']['code'] = TRUE;
$fout['input']['code'] = TRUE;
}
}
if(!empty( $aFout ))
{
$errors = '
<div id="errors">
<ul>';
foreach($aFout as $sFout)
{
$errors .= " <li>".$sFout."</li>\n";
}
$errors .= "</ul>
</div>";
}
else
{
$formulier = FALSE;
}
}
if($formulier)
{
?>
<!DOCTYPE html>
<html lang="nl-NL">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>xxx</title>
<link rel="stylesheet" href="/css/contactform.css" type="text/css" />
<link rel="stylesheet" href="/css/styles.css" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="main">
<div id="header" role="banner">
<div id="header_menu">
<nav role="navigation"><ul class="menu">
<li class="item-101"><a href="/">xxx</a></li>
<li class="item-102"><a href="/">xxx</a></li>
<li class="item-136"><a href="/">xxx</a></li>
<li class="item-103"><a href="/">xxx</a></li>
<li class="item-105"><a href="/">xxx</a></li>
<li class="item-142"><a href="/">xxx</a></li></ul></nav>
</div><!-- end header_menu -->
</div><!-- end header -->
<div id="leftbar"> <!-- Linkerkant met alle modules -->
<div class="leftbar-title">Login of registreer</div>
<div id="module_inlog"> <!-- Begin module inloggen -->
<div class="module-title"></div>
<div class="module-body">
<form action="/" method="post" id="login-form" >
<p id="form-login-username">
<label for="modlgn-username">Email</label>
<input id="modlgn-username" required autocomplete="off" type="text" name="username" class="inputbox" size="16" />
</p>
<p id="form-login-password">
<label for="modlgn-passwd">Wachtwoord</label>
<input id="modlgn-passwd" required autocomplete="off" type="password" name="password" class="inputbox" size="16" />
</p>
<p id="form-login-remember">
<label for="modlgn-remember">Onthoud mij</label>
<input id="modlgn-remember" type="checkbox" name="remember" class="checkbox" value="yes"/>
</p>
<input type="submit" name="Submit" class="b_inloggen" value="Inloggen" />
</form>
<span class="w-vergeten"><a rel="nofollow" target="_blank" href="forgot.php" title="Wachtwoord vergeten">Wachtwoord vergeten?</a>
</span> <!-- end w-vergeten -->
</div> <!-- end module-body -->
</div> <!-- end module_inlog -->
</div> <!-- end leftbar -->
<div id="centercontent" role="main">
<h1>Registreer</h1><br /><br />
<?php
if(isset($errors)) {
echo $errors;
}
?>
<form action="register_form.php" name="contactformulier" id="contactformulier" method="post" class="Chronoform">
<div class="contactform firstname" >
<label for="firstname"<?php if(isset($fout['text']['firstname'])) { echo 'class="fout"'; } ?>>firstname:*</label>
<input type="text" title="Vul uw firstname in." id="firstname" name="firstname" size="45" <?php if(isset($fout['input']['firstname'])) { echo 'class="fout"'; } ?> value="<?php if (!empty($firstname)) { echo stripslashes($firstname); } ?>" />
</div>
<div class="contactform lastname" >
<label for="lastname"<?php if(isset($fout['text']['lastname'])) { echo 'class="fout"'; } ?>>lastname:*</label>
<input type="text" title="Vul uw lastname in." id="lastname" name="lastname" size="45" <?php if(isset($fout['input']['lastname'])) { echo 'class="fout"'; } ?> value="<?php if (!empty($lastname)) { echo stripslashes($lastname); } ?>" />
</div>
<div class="contactform email" >
<label for="email"<?php if(isset($fout['text']['email'])) { echo 'class="fout"'; } ?>>Email:*</label>
<input type="text" title="Vul uw email in." id="email" name="email" size="45" <?php if(isset($fout['input']['email'])) { echo 'class="fout"'; } ?> value="<?php if (!empty($email)) { echo stripslashes($email); } ?>" />
</div>
<div class="contactform password" >
<label for="password"<?php if(isset($fout['text']['password'])) { echo 'class="fout"'; } ?>>password:*</label>
<input type="text" title="Vul uw password in." id="password" name="password" size="45" <?php if(isset($fout['input']['password'])) { echo 'class="fout'; } ?> value="<?php if (!empty($password)) { echo stripslashes($password); } ?>" />
</div>
<?php
if(TRUE)
{
?>
<div class="contactform code" >
<label for="code"<?php if(isset($fout['text']['code'])) { echo 'class="fout"'; } ?>>Vul de code in:*</label>
<input type="text" title="Vul de code in." id="code" name="code" size="24" <?php if(isset($fout['input']['code'])) { echo 'class="captcha fout"'; } ?> />
<span class="captcha_image"><img src="/test/contact/captcha.php" width="100" height="28" alt="" title="Code"/></span>
<?php
}
?>
</div>
<div class="contactform submit" >
<input type="submit" id="verzenden" name="register" class="b_verzenden" value="verzenden" />
</div>
</form>
</div><!-- end centercontent -->
</div><!-- end main -->
</div><!-- end wrapper -->
<div id="footer" role="contentinfo">
<footer>
</footer>
</div><!-- end footer -->
</body>
</html>
<?php
}
?>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (isset($_POST['login'])) { //user logging in
require 'login.php';
}
elseif (isset($_POST['register'])) { //user registering
require 'register.php';
}
}
?>
require 'db_connect.php';
session_start();
ini_set( 'display_errors', true );
error_reporting( E_ALL | E_STRICT );
// E-mail Checker / Validator.
function checkmail($email)
{
if (preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i", $email))
{
list($userName, $mailDomain) = split("@", $email);
if (checkdnsrr($mailDomain, "MX")) {
return TRUE;
}
}
return FALSE;
}
$formulier = TRUE;
if(isset($_POST['register']) && ($_SERVER['REQUEST_METHOD'] == "POST"))
{
$aFout = array();
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$password = $_POST['password'];
if(TRUE)
{
$code = $_POST['code'];
}
// Als $firstname leeg is of $voonaam minder dan 2 tekens bevat of deze bepaalde tekens bevat preg_match) dan word de uitvoer Fout. (||=of)(&&=AND).
if(empty($firstname) || (strlen($firstname) < 2) || preg_match("[<>]", $firstname) )
{
$aFout[] = "Er is geen firstname ingevuld.";
unset($firstname);
$fout['text']['firstname'] = TRUE;
$fout['input']['firstname'] = TRUE;
}
// Als $lastname leeg is of $lastname minder dan 2 tekens bevat of deze bepaalde tekens bevat preg_match) dan word de uitvoer Fout. (||=of)(&&=AND).
if(empty($lastname) || (strlen($lastname) < 2) || preg_match("[<>]", $lastname) )
{
$aFout[] = "Er is geen lastname ingevuld.";
unset($lastname);
$fout['text']['lastname'] = TRUE;
$fout['input']['lastname'] = TRUE;
}
if(empty($email))
{
$aFout[] = "Er is geen e-mail adres ingevuld.";
unset($email);
$fout['text']['email'] = TRUE;
$fout['input']['email'] = TRUE;
}
elseif(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
$aFout[] = "Er is geen correct e-mail adres ingevuld.";
unset($email);
$fout['text']['email'] = TRUE;
$fout['input']['email'] = TRUE;
}
if(empty($password))
{
$aFout[] = "Er is geen password ingevuld.";
unset($password);
$fout['text']['password'] = TRUE;
$fout['input']['password'] = TRUE;
}
if(TRUE)
{
if(strtoupper($code) != $_SESSION['captcha_code'])
{
$aFout[] = "Er is geen correcte code ingevuld.";
$fout['text']['code'] = TRUE;
$fout['input']['code'] = TRUE;
}
}
if(!empty( $aFout ))
{
$errors = '
<div id="errors">
<ul>';
foreach($aFout as $sFout)
{
$errors .= " <li>".$sFout."</li>\n";
}
$errors .= "</ul>
</div>";
}
else
{
$formulier = FALSE;
}
}
if($formulier)
{
?>
<!DOCTYPE html>
<html lang="nl-NL">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>xxx</title>
<link rel="stylesheet" href="/css/contactform.css" type="text/css" />
<link rel="stylesheet" href="/css/styles.css" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="main">
<div id="header" role="banner">
<div id="header_menu">
<nav role="navigation"><ul class="menu">
<li class="item-101"><a href="/">xxx</a></li>
<li class="item-102"><a href="/">xxx</a></li>
<li class="item-136"><a href="/">xxx</a></li>
<li class="item-103"><a href="/">xxx</a></li>
<li class="item-105"><a href="/">xxx</a></li>
<li class="item-142"><a href="/">xxx</a></li></ul></nav>
</div><!-- end header_menu -->
</div><!-- end header -->
<div id="leftbar"> <!-- Linkerkant met alle modules -->
<div class="leftbar-title">Login of registreer</div>
<div id="module_inlog"> <!-- Begin module inloggen -->
<div class="module-title"></div>
<div class="module-body">
<form action="/" method="post" id="login-form" >
<p id="form-login-username">
<label for="modlgn-username">Email</label>
<input id="modlgn-username" required autocomplete="off" type="text" name="username" class="inputbox" size="16" />
</p>
<p id="form-login-password">
<label for="modlgn-passwd">Wachtwoord</label>
<input id="modlgn-passwd" required autocomplete="off" type="password" name="password" class="inputbox" size="16" />
</p>
<p id="form-login-remember">
<label for="modlgn-remember">Onthoud mij</label>
<input id="modlgn-remember" type="checkbox" name="remember" class="checkbox" value="yes"/>
</p>
<input type="submit" name="Submit" class="b_inloggen" value="Inloggen" />
</form>
<span class="w-vergeten"><a rel="nofollow" target="_blank" href="forgot.php" title="Wachtwoord vergeten">Wachtwoord vergeten?</a>
</span> <!-- end w-vergeten -->
</div> <!-- end module-body -->
</div> <!-- end module_inlog -->
</div> <!-- end leftbar -->
<div id="centercontent" role="main">
<h1>Registreer</h1><br /><br />
<?php
if(isset($errors)) {
echo $errors;
}
?>
<form action="register_form.php" name="contactformulier" id="contactformulier" method="post" class="Chronoform">
<div class="contactform firstname" >
<label for="firstname"<?php if(isset($fout['text']['firstname'])) { echo 'class="fout"'; } ?>>firstname:*</label>
<input type="text" title="Vul uw firstname in." id="firstname" name="firstname" size="45" <?php if(isset($fout['input']['firstname'])) { echo 'class="fout"'; } ?> value="<?php if (!empty($firstname)) { echo stripslashes($firstname); } ?>" />
</div>
<div class="contactform lastname" >
<label for="lastname"<?php if(isset($fout['text']['lastname'])) { echo 'class="fout"'; } ?>>lastname:*</label>
<input type="text" title="Vul uw lastname in." id="lastname" name="lastname" size="45" <?php if(isset($fout['input']['lastname'])) { echo 'class="fout"'; } ?> value="<?php if (!empty($lastname)) { echo stripslashes($lastname); } ?>" />
</div>
<div class="contactform email" >
<label for="email"<?php if(isset($fout['text']['email'])) { echo 'class="fout"'; } ?>>Email:*</label>
<input type="text" title="Vul uw email in." id="email" name="email" size="45" <?php if(isset($fout['input']['email'])) { echo 'class="fout"'; } ?> value="<?php if (!empty($email)) { echo stripslashes($email); } ?>" />
</div>
<div class="contactform password" >
<label for="password"<?php if(isset($fout['text']['password'])) { echo 'class="fout"'; } ?>>password:*</label>
<input type="text" title="Vul uw password in." id="password" name="password" size="45" <?php if(isset($fout['input']['password'])) { echo 'class="fout'; } ?> value="<?php if (!empty($password)) { echo stripslashes($password); } ?>" />
</div>
<?php
if(TRUE)
{
?>
<div class="contactform code" >
<label for="code"<?php if(isset($fout['text']['code'])) { echo 'class="fout"'; } ?>>Vul de code in:*</label>
<input type="text" title="Vul de code in." id="code" name="code" size="24" <?php if(isset($fout['input']['code'])) { echo 'class="captcha fout"'; } ?> />
<span class="captcha_image"><img src="/test/contact/captcha.php" width="100" height="28" alt="" title="Code"/></span>
<?php
}
?>
</div>
<div class="contactform submit" >
<input type="submit" id="verzenden" name="register" class="b_verzenden" value="verzenden" />
</div>
</form>
</div><!-- end centercontent -->
</div><!-- end main -->
</div><!-- end wrapper -->
<div id="footer" role="contentinfo">
<footer>
</footer>
</div><!-- end footer -->
</body>
</html>
<?php
}
?>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (isset($_POST['login'])) { //user logging in
require 'login.php';
}
elseif (isset($_POST['register'])) { //user registering
require 'register.php';
}
}
?>
Dit is het registratie script:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/* Registration process, inserts user info into the database
and sends account confirmation email message
*/
// Set session variables to be used on profile.php page
$_SESSION['email'] = $_POST['email'];
$_SESSION['first_name'] = $_POST['firstname'];
$_SESSION['last_name'] = $_POST['lastname'];
// Escape all $_POST variables to protect against SQL injections
$first_name = $mysqli->escape_string($_POST['firstname']);
$last_name = $mysqli->escape_string($_POST['lastname']);
$email = $mysqli->escape_string($_POST['email']);
$password = $mysqli->escape_string(password_hash($_POST['password'], PASSWORD_BCRYPT));
$hash = $mysqli->escape_string( md5( rand(0,1000) ) );
// Check if user with that email already exists
$result = $mysqli->query("SELECT * FROM users WHERE email='$email'") or die($mysqli->error());
// We know user email exists if the rows returned are more than 0
if ( $result->num_rows > 0 ) {
$_SESSION['message'] = 'User with this email already exists!';
header("location: error.php");
}
else { // Email doesn't already exist in a database, proceed...
// active is 0 by DEFAULT (no need to include it here)
$sql = "INSERT INTO users (first_name, last_name, email, password, hash) "
. "VALUES ('$first_name','$last_name','$email','$password', '$hash')";
// Add user to the database
if ( $mysqli->query($sql) ){
$_SESSION['active'] = 0; //0 until user activates their account with verify.php
$_SESSION['logged_in'] = true; // So we know the user has logged in
$_SESSION['message'] =
"Confirmation link has been sent to $email, please verify
your account by clicking on the link in the message!";
// Send registration confirmation link (verify.php)
$to = $email;
$subject = 'Account Verification ( clevertechie.com )';
$message_body = '
Hello '.$first_name.',
Thank you for signing up!
Please click this link to activate your account:
http://localhost/verify.php?email='.$email.'&hash='.$hash;
mail( $to, $subject, $message_body );
header("location: profile.php");
}
else {
$_SESSION['message'] = 'Registration failed!';
header("location: error.php");
}
}
?>
/* Registration process, inserts user info into the database
and sends account confirmation email message
*/
// Set session variables to be used on profile.php page
$_SESSION['email'] = $_POST['email'];
$_SESSION['first_name'] = $_POST['firstname'];
$_SESSION['last_name'] = $_POST['lastname'];
// Escape all $_POST variables to protect against SQL injections
$first_name = $mysqli->escape_string($_POST['firstname']);
$last_name = $mysqli->escape_string($_POST['lastname']);
$email = $mysqli->escape_string($_POST['email']);
$password = $mysqli->escape_string(password_hash($_POST['password'], PASSWORD_BCRYPT));
$hash = $mysqli->escape_string( md5( rand(0,1000) ) );
// Check if user with that email already exists
$result = $mysqli->query("SELECT * FROM users WHERE email='$email'") or die($mysqli->error());
// We know user email exists if the rows returned are more than 0
if ( $result->num_rows > 0 ) {
$_SESSION['message'] = 'User with this email already exists!';
header("location: error.php");
}
else { // Email doesn't already exist in a database, proceed...
// active is 0 by DEFAULT (no need to include it here)
$sql = "INSERT INTO users (first_name, last_name, email, password, hash) "
. "VALUES ('$first_name','$last_name','$email','$password', '$hash')";
// Add user to the database
if ( $mysqli->query($sql) ){
$_SESSION['active'] = 0; //0 until user activates their account with verify.php
$_SESSION['logged_in'] = true; // So we know the user has logged in
$_SESSION['message'] =
"Confirmation link has been sent to $email, please verify
your account by clicking on the link in the message!";
// Send registration confirmation link (verify.php)
$to = $email;
$subject = 'Account Verification ( clevertechie.com )';
$message_body = '
Hello '.$first_name.',
Thank you for signing up!
Please click this link to activate your account:
http://localhost/verify.php?email='.$email.'&hash='.$hash;
mail( $to, $subject, $message_body );
header("location: profile.php");
}
else {
$_SESSION['message'] = 'Registration failed!';
header("location: error.php");
}
}
?>
Bij het origineel staat dit stukje
Code (php)
Helemaal boven aan. Als ik dat hier doe dan krijg ik gelijk de melding dat het email adres al bestaat nog voor ik iets heb ingevuld. Heeft iemand een idee waarom het gelijk de datbase ingeschreven wordt of waarom er gelijk de melding komt dat het email adres al bestaat als dit stukje boven aan staat?
- Ariën -:
Gelieve in het vervolg bij code de [code][/code]-tags gebruiken.
Hier kan je meer lezen over de mogelijke opmaakcodes.
Alvast bedankt!
Hier kan je meer lezen over de mogelijke opmaakcodes.
Alvast bedankt!
Gewijzigd op 21/08/2017 13:19:59 door - Ariën -
Gebruik gewoon de php functie filter_input() met het juiste filter om een email adres te herkennen.
verder wemelt je code van de stripslashes() waar je htmlspecialchars() bedoelt.
Je preg_match functies zijn raar: ik denk dan je ~[<>]~ bedoelt? (al blijft het matigjes)
En tenslotte:
vermoedelijk wil je alleen register.php includen als !isset($errors)
Bedankt voor de reactie. Ben net terug van vakantie en ga er weer mee verder met hopelijk meer succes als voor de vakantie.