-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent_registration.php
More file actions
225 lines (190 loc) · 6.62 KB
/
Copy pathstudent_registration.php
File metadata and controls
225 lines (190 loc) · 6.62 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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<!DOCTYPE html>
<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">
<title>register</title>
<!-- font awesome cdn link -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css">
<!-- custom css file link -->
<link rel="stylesheet" href="css/style.css">
<!-- custom css file link -->
<link rel="stylesheet" href="CSS_Student/style.css">
</head>
<body>
<section class="form-container">
<form action="student_registration.php" name="register_form" method="post" enctype="multipart/form-data" onsubmit="return validateForm()">
<h3>register new student</h3>
<p>First name <span>*</span></p>
<input type="text" name="fname" onkeyup="showHint(this.value)" placeholder="enter your first name" required maxlength="50" class="box">
<span id="txtHint"></span></td>
<p>Last name <span>*</span></p>
<input type="text" name="lname" onkeyup="showHint1(this.value)" placeholder="enter your last name" required maxlength="50" class="box">
<span id="txtHint1"></span></td>
<p>User name <span>*</span></p>
<input type="text" name="uname" onkeyup="showHint2(this.value)" placeholder="enter your user name" required maxlength="50" class="box">
<span id="txtHint2"></span></td>
<p>Date of birth <span>*</span></p>
<input type="date" name="dob" placeholder="enter your date of birth" required maxlength="50" class="box">
<p>Gender <span>*</span></p>
<P><input type="radio" name="gender" value="Male" required> Male
<input type="radio" name="gender" value="Female" required> Female</p>
<p>E-mail <span>*</span></p>
<input type="email" name="email" placeholder="enter your email" required maxlength="50" class="box">
<p>Phone <span>*</span></p>
<input type="text" name="phone" placeholder="enter your user name" required maxlength="50" class="box">
<p>Address <span>*</span></p>
<input type="text" name="address" placeholder="enter your address" required maxlength="50" class="box">
<p>Password <span>*</span></p>
<input type="password" name="password" placeholder="enter your password" required maxlength="20" class="box">
<p>Confirm password <span>*</span></p>
<input type="password" name="pass1" placeholder="confirm your password" required maxlength="20" class="box">
<p>select profile <span>*</span></p>
<input type="file" accept="image/*" required class="box">
<input type="submit" value="register now" name="submit" class="btn">
<center><button class="btn"><a href="manage_student.php" class="">Cancel
</a></button></center>
</form>
</section>
<!-- custom js file link -->
<script src="js/script.js"></script>
<script>
function validateForm() {
var username = document.forms["register_form"]["uname"].value;
var password = document.forms["register_form"]["password"].value;
var pass1 = document.forms["register_form"]["pass1"].value;
if (username === "") {
alert("Username must be filled out");
return false;
}
if (password === "") {
alert("Password must be filled out");
return false;
}
if (password !== pass1) {
alert('Passwords do not match.');
return false;
}
return true;
}
</script>
<!-- custom js file link -->
<script src="JavaScript_Student/script.js"></script>
</body>
</html>
</body>
</html>
<?php
@include 'dbcon.php';
if(isset($_POST['submit']))
{
session_start();
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$uname = $_POST['uname'];
$dob = $_POST['dob'];
$gender = $_POST['gender'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$password = $_POST['password'];
$pass1 = $_POST['pass1'];
$_SESSION['fname'] = $fname;
$_SESSION['lname'] = $lname;
$_SESSION['uname'] = $uname;
$_SESSION['dob'] = $dob;
$_SESSION['gender'] = $gender;
$_SESSION['email'] = $email;
$_SESSION['phone'] = $phone;
$_SESSION['address'] = $address;
$_SESSION['password'] = $password;
if($password == $pass1)
{
$sql = "INSERT INTO `student_registration`(`fname`, `lname`, `uname`, `DOB`, `gender`, `email`, `phone`, `address`, `password`)
VALUES
('$fname',' $lname','$uname','$dob ','$gender','$email','$phone','$address','$password')";
$result=mysqli_query($conn,$sql);
if($result)
{
$newUserId = $conn->s_id;
header("Location: admin_added_student.php");
}
else
{
echo "<i>Password doesn't match</i>";
}
}
}
?>
<?php
if(isset($_POST['Back']))
{
header('location:manage_student.php');
}
?>
<script>
function validateForm() {
var username = document.querySelector('.register_form input[name="username"]').value;
var password = document.querySelector('.register_form input[name="password"]').value;
var pass1 = document.querySelector('.register_form input[name="pass1"]').value;
if (username === "") {
alert("Username must be filled out");
return false;
}
if (password === "") {
alert("Password must be filled out");
return false;
}
if (password !== pass1) {
alert('Passwords do not match.');
return false;
}
return true;
}
</script>
<script>
function showHint(str) {
if (str.length == 0) {
document.getElementById("txtHint").innerHTML = "";
return;
} else {
const xmlhttp = new XMLHttpRequest();
xmlhttp.onload = function() {
document.getElementById("txtHint").innerHTML = this.responseText;
}
xmlhttp.open("GET", "get_fname.php?q=" + str);
xmlhttp.send();
}
}
</script>
<script>
function showHint1(str) {
if (str.length == 0) {
document.getElementById("txtHint1").innerHTML = "";
return;
} else {
const xmlhttp = new XMLHttpRequest();
xmlhttp.onload = function() {
document.getElementById("txtHint1").innerHTML = this.responseText;
}
xmlhttp.open("GET", "get_lname.php?q=" + str);
xmlhttp.send();
}
}
</script>
<script>
function showHint2(str) {
if (str.length == 0) {
document.getElementById("txtHint2").innerHTML = "";
return;
} else {
const xmlhttp = new XMLHttpRequest();
xmlhttp.onload = function() {
document.getElementById("txtHint2").innerHTML = this.responseText;
}
xmlhttp.open("GET", "get_uname.php?q=" + str);
xmlhttp.send();
}
}
</script>