-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.signup.php
61 lines (50 loc) · 1.75 KB
/
web.signup.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
<?php
include 'connection.php';
if(isset($_POST["submit"])) {
$username = $_POST["username"];
$password = $_POST["password"];
$cpassword = $_POST["cpassword"];
$userpass = sha1($password);
$insert = "INSERT INTO users (username, password) VALUES ('$username', '$userpass')";
$insert2 = "INSERT INTO timestamps(username) VALUES ('$username')";
$insert3 = "INSERT INTO settings(username) VALUES ('$username')";
$check_username = mysqli_query($connection, "SELECT username FROM users WHERE username = '$username' ");
if(strlen($username) < 3) {
print(strlen($username));
header("location: registerpage.php?error=usernametooshort");
exit();
}
if(strlen($password) < 5) {
print(strlen($password));
header("location: registerpage.php?error=passwordtooshort");
exit();
}
if($password !== $cpassword) {
header("location: registerpage.php?error=notmatching");
exit();
}
if(!preg_match("/^[a-zA-Z0-9]*$/", $username)) {
header("location: registerpage.php?error=emptyusername");
exit();
}
if(empty($password) || empty($cpassword)) {
header("location: registerpage.php?error=emptyfield");
exit();
}
if(mysqli_num_rows($check_username) > 0){
header("location: registerpage.php?error=usernametaken");
exit();
}
if ($connection->query($insert) === TRUE) {
if($connection->query($insert2) === TRUE) {
if($connection->query($insert3) === TRUE) {
header("location: loginpage.php?error=successful");
exit();
}
}
}
$connection -> close();
} else {
header("location: registerpage.php");
exit();
}