/
adduser_submit.php
83 lines (79 loc) · 1.93 KB
/
adduser_submit.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
<?php
include_once("db_connect.inc.php");
if(!empty($_POST)){
$username = $_POST["Username"];
$password = $_POST["Password"];
$hash = password_hash($password, PASSWORD_DEFAULT);
$email = $_POST["Email"];
$from = $_POST["from"];
$query = "";
if(isset($_POST["Username"], $_POST["Password"], $_POST["Email"])){
if(strlen($username) <= 20 && strlen($username) >= 4 && strlen($password) <= 20 && strlen($password) >= 4){
if(ctype_alnum($username)){
if(ctype_alnum($password)){
$query = "INSERT users (Username, Password, email) ";
$query .= "VALUES ('";
$query .= $username."','";
$query .= $hash."','";
$query .= $email."')";
if(!mysql_query($query)){
echo "The user already exists";
/*echo "Er is een fout opgetreden met nummer ". mysql_errno().":" . mysql_error();
echo $query;
mysql_close($db);
exit;*/
}
else{
$bedankt .="?id=". mysql_insert_id($db);
mysql_close($db);
if($from != ""){
header("Refresh:0; url=$from");
}
}
}else{
echo "Your password must be alpha numeric";
}
}else{
echo "Your username must be alpha numeric";
}
}else{
echo "Your username or password must be at least 5 and at most 19";
}
}else{
echo "Please fill in all fields";
}
}
else{
?>
<html>
<head>
<title>Account registration</title>
</head>
<body>
<?php
?>
<h2>Add user</h2>
<form method="post" id="userreg" action="<?php echo $_SERVER["PHP_SELF"] ?>"><table>
<fieldset>
<p>
<label for="Username">Username</label>
<input type="text" id="username" name="Username" value="" maxlength="20" />
</p>
<p>
<label for="Password">Password</label>
<input type="text" id="password" name="Password" value="" maxlength="20" />
</p>
<p>
<label for="Email">E-mail</label>
<input type="text" id="Email" name="Email" value="" maxlength="20" />
</p>
<p>
<input type="submit" value="Login" />
</p>
</fieldset>
</form>
</body>
</html>
<?php
}
?>