-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignUp.php
More file actions
74 lines (62 loc) · 1.98 KB
/
Copy pathSignUp.php
File metadata and controls
74 lines (62 loc) · 1.98 KB
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
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "lms";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Get form data
$first_name = $_POST["first_name"];
$last_name = $_POST["last_name"];
$user_id = $_POST["user_id"];
$email = $_POST["email"];
$password = $_POST["password"];
$re_password = $_POST["re_password"];
$dob = $_POST["dob"];
$phone_number=$_POST['phone_number'];
$gender = $_POST["gender"];
if ($password!=$re_password) {
echo '<script type= "text/javascript"> ;
alert("Passwords do not match");
window.location.href="SignUp.html";
</script>';
exit();
}
// Check if duplicate account
$dupesql = "SELECT * FROM user where user_id='$user_id' OR email='$email'";
if($duperaw = mysqli_query($conn,$dupesql))
{if (mysqli_num_rows($duperaw) > 0) {
echo '<script type= "text/javascript"> ;
alert("An account is already created with this email or user_id");
window.location.href="SignUp.html";
</script>';
mysqli_close($conn);
exit();
}}
else
{
echo '<script type= "text/javascript"> ;
alert("An Error Occured");
window.location.href="SignUp.html";
</script>';
mysqli_close($conn);
exit();
}
// Insert data into table
$sql = "INSERT INTO user (first_name,last_name,user_id,email,password,date_of_birth,gender,phone_number)
VALUES ('$first_name','$last_name','$user_id','$email','$password','$dob','$gender','$phone_number')";
// Check if record was successfully inserted
if (mysqli_query($conn, $sql)) {
echo '<script type= "text/javascript"> ;
alert("Account Created Successfully");
window.location.href="SignUp.html";
</script>';
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
?>