-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
48 lines (42 loc) · 1.26 KB
/
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
<?php
if(isset($_POST['submitted'])==1){
$id_st = 0;
$pwd_st = 0;
$email_st = 0;
$id = $_POST['id'];
$pwd = mysqli_real_escape_string($dbc, $_POST['pwd']);
$re_pwd = mysqli_real_escape_string($dbc, $_POST['re-pwd']);
$email = $_POST['email'];
$q1 = "SELECT * FROM users WHERE email = '$email'";
$q2 = "SELECT * FROM users WHERE id = '$id'";
if($pwd == $re_pwd){
$pwd_st = 1;
if(mysqli_num_rows(mysqli_query($dbc, $q1)) == 0){
$email_st = 1;
if(mysqli_num_rows(mysqli_query($dbc, $q2)) == 0){
$id_st = 1;
$q = "INSERT INTO users (id, pwd, email) VALUES ('$id', SHA1('$pwd'), '$email')";
$data = mysqli_query($dbc, $q);
if($data){
echo "<p class='alert alert-success'>Registration Succesful</p>";
}
else{
echo "<p class='alert alert-danger'>Registration failed due to technical error. Please try again...</p>";
}
}
else{
echo "<p class='alert alert-danger'>Username not available</p>";
$id_st = -1;
}
}
else{
echo "<p class='alert alert-danger'>The email address you have entered is already registered</p>";
$email_st = -1;
}
}
else{
echo "<p class='alert alert-warning'>Passwords don't match. Please try again...</p>";
$pwd_st = -1;
}
}
?>