-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstudentSignUp.php
112 lines (97 loc) · 4.18 KB
/
studentSignUp.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
105
106
107
108
109
110
111
112
<?php
include 'config.php';
error_reporting(0);
session_start();
if (isset($_SESSION['user_name'])) {
header("Location: studentDashboard.php");
}
if (isset($_POST['submit'])) {
$user_name = $_POST['username'];
$First_name = $_POST['First_name'];
$Last_name = $_POST['Last_name'];
$email = $_POST['email'];
$contact_no = $_POST['contact_no'];
$Class_number = $_POST['Class_number'];
$student_id = $_POST['student_id'];
$password = $_POST['password'];
$checkPassword = $_POST['checkPassword'];
if ($password == $checkPassword) {
// if the student exists or not
$sql = "SELECT * FROM student WHERE student_id='$student_id'";
$result = mysqli_query($conn, $sql);
if (!$result->num_rows > 0) {
$sql = "INSERT INTO student (First_name , Last_name , user_name ,
contact_no , password , email , student_id , Class_number)
VALUES ('$First_name', '$Last_name', '$user_name', '$contact_no',
'$password', '$email', '$student_id', '$Class_number')";
$result = mysqli_query($conn, $sql);
if ($result) {
echo "<script>alert('Student Signup Done.')</script>";
$user_name = "";
$First_name = "";
$Last_name = "";
$email = "";
$contact_no = "";
$Class_number = "";
$student_id = "";
$_POST['password'] = "";
$_POST['checkPassword'] = "";
} else {
echo "<script>alert('Something Went Wrong.')</script>";
}
} else {
echo "<script>alert('This Student Already Exists.')</script>";
}
} else {
echo "<script>alert('Password Not Matched.')</script>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="style.css">
<title>studentSignUp</title>
</head>
<body>
<div class="container">
<form action="" method="POST" class="login-email">
<p class="login-text" style="font-size: 2rem; font-weight: 800;">Register</p>
<div class="input-group">
<input type="text" placeholder="Student ID" name="student_id" value="<?php echo $student_id; ?>" required>
</div>
<div class="input-group">
<input type="text" placeholder="First name" name="First_name" value="<?php echo $First_name; ?>" required>
</div>
<div class="input-group">
<input type="text" placeholder="Last name" name="Last_name" value="<?php echo $Last_name; ?>" required>
</div>
<div class="input-group">
<input type="text" placeholder="User name" name="user_name" value="<?php echo $user_name; ?>" required>
</div>
<div class="input-group">
<input type="text" placeholder="Class number" name="Class_number" value="<?php echo $Class_number; ?>" required>
</div>
<div class="input-group">
<input type="text" placeholder="contact no" name="contact_no" value="<?php echo $contact_no; ?>" required>
</div>
<div class="input-group">
<input type="email" placeholder="Email" name="email" value="<?php echo $email; ?>" required>
</div>
<div class="input-group">
<input type="password" placeholder="Password" name="password" value="<?php echo $_POST['password']; ?>" required>
</div>
<div class="input-group">
<input type="password" placeholder="Confirm Password" name="checkPassword" value="<?php echo $_POST['checkPassword']; ?>" required>
</div>
<div class="input-group">
<button name="submit" class="btn">Register</button>
</div>
<p class="login-register-text">Have an account? <a href="studentLogin.php">Login Here</a>.</p>
</form>
</div>
</body>
</html>