-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup_process.php
61 lines (55 loc) · 1.86 KB
/
signup_process.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
<html>
<head>
<title>Connection</title>
</head>
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$db_name = "web_design";
$conn = mysqli_connect($servername, $username, $password, $db_name);
if(!$conn)
die("Error connecting to the database".mysqli_connect_error());
else
echo "Connected successfully!!! <br>";
session_start();
$firstName = $_POST['firstName'];
$middleName = $_POST['middleName'];
$lastName = $_POST['lastName'];
$email = $_POST['email'];
$mobileNo = $_POST['mobileNo'];
$password = $_POST['password'];
$confirmPassword = $_POST['confirmPassword'];
$gender = $_POST['gender'];
$date_of_birth = $_POST['dob'];
$date = strtotime($date_of_birth);
$dob = date("Y-m-d", $date);
$_SESSION['email'] = $email;
$emailCheckQuery = mysqli_query($conn, "SELECT * FROM user_details WHERE email = '$email'");
if($password != $confirmPassword){
echo "Passwords do not match";
header("location:signup.html");
}
else{
if(mysqli_num_rows($emailCheckQuery) > 0){
echo "Email ID already exists";
header("location:signup.html");
}
else{
$sql = "INSERT INTO user_details (`id`, `firstName`, `middleName`, `lastName`, `email`, `mobileNo`, `password`, `gender`, `date_of_birth`) VALUES (NULL, '$firstName','$middleName', '$lastName', '$email', '$mobileNo', '$password', '$gender', '$dob')";
if(mysqli_query($conn, $sql)){
$subject = "Thanks for registering online!!!";
$msg = "We welcome to join your journey with us";
$headers = "From: [email protected]";
mail($email, $subject, $msg, $headers);
header("Location:profile.php");
}
else{
echo("Error submitting record <br>".mysqli_error($conn));
}
}
}
?>
</body>
</html>