-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignupUser.php
104 lines (96 loc) · 4.71 KB
/
signupUser.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<?php
include "./includes/start_navbar.inc.php";
include "./includes/config.inc.php";
$message = "";
if (isset($_POST["submit"])) {
$name = $_POST["name"];
$phone = $_POST["phone"];
$email = $_POST["email"];
$password = $_POST["password"];
$confirm_password = $_POST["confirmPassword"];
date_default_timezone_set('Asia/Kolkata');
$current_date_time = date('d/m/Y h:i A');
$status = "active";
$sql_check = "select * from `students` where name='$name' and email='$email'";
$userList = mysqli_query($conn, $sql_check);
if ($userList) {
$row = mysqli_fetch_assoc($userList);
if ($row) {
$message = "User is already present....";
} else {
if ($confirm_password != $password) {
$message = "Password and Confirm password not match....";
} else {
$sql = "insert into `students` (name,mobile,email,password,reg_date,status) values('$name','$phone','$email','$password','$current_date_time','$status')";
$result = mysqli_query($conn, $sql);
// mysqli_error($conn);
if ($result) {
$id_result = mysqli_query($conn, $sql_check);
if ($id_result) {
while ($row = mysqli_fetch_assoc($id_result)) {
$id = $row["id"];
$studentId = "SID" . $id;
$sql_id = "UPDATE `students` SET studentId = '$studentId' WHERE id='$id';";
$addId = mysqli_query($conn, $sql_id);
if ($addId) {
echo "<script>alert('Your studentId is " . $studentId . "')</script>";
echo "<script>window.location.href = \"index.php\"</script>";
// header("location:index.php");
} else {
$message = "Something went wrong please try again....";
}
}
} else {
$message = "Something went wrong please try again....";
}
} else {
$message = "Something went wrong please try again....";
}
}
}
}
}
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.rtl.min.css" integrity="sha384-T5m5WERuXcjgzF8DAb7tRkByEZQGcpraRTinjpywg37AO96WoYN9+hrhDVoM6CaT" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<title>User Signup</title>
</head>
<body>
<div class="container h-100 w-100 mx-5 my-0">
<h2 class="p-3">User SignUp Form</h2>
<form class="px-5" method="post">
<div class="mb-2">
<label for="exampleInputEmail1" class="form-label">Enter Full Name : </label>
<input type="text" name="name" class="form-control w-50" id="exampleInputname">
</div>
<div class="mb-2">
<label for="exampleInputEmail1" class="form-label">Mobile Number : </label>
<input type="text" name="phone" class="form-control w-50" id="exampleInputphone">
</div>
<div class="mb-2">
<label for="exampleInputEmail1" class="form-label">Enter Email : </label>
<input type="email" name="email" class="form-control w-50" id="exampleInputEmail1" aria-describedby="emailHelp">
</div>
<div class="mb-2">
<label for="exampleInputEmail1" class="form-label">Enter Password : </label>
<input type="password" name="password" class="form-control w-50" id="exampleInputpass" autocomplete="FALSE">
</div>
<div class="mb-2">
<label for="exampleInputPassword1" class="form-label">Confirm Password : </label>
<input type="password" name="confirmPassword" class="form-control w-50" id="exampleInputPassword1" autocomplete="FALSE">
</div>
<button name="submit" type="submit" class="btn btn-primary">SignUp</button>
</form>
<?php
echo "<p class=\"error text-danger p-3 m-3\">$message</p>";
?>
</div>
</body>
</html>