-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent_signup.php
More file actions
277 lines (180 loc) · 16.4 KB
/
Copy pathstudent_signup.php
File metadata and controls
277 lines (180 loc) · 16.4 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<?php require_once("./includes/header.php"); ?>
<div>
<center><h1>IIIT Kalyani Exam Portal<h1></center>
</div>
<!-- Java script to enable/disable Ronn no text box-->
<script type="text/javascript">
//Validating registration number to accept number only
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
</script>
<main>
<!--.................................Signup handelling start...............................................................-->
<?php
if(isset($_POST['submit']))
{
$user_type = trim($_POST['user-type']);
if ($user_type=='Student') {
$salutation = '';
}else{
$salutation = trim($_POST['salutation']);
}
$first_name = trim($_POST['first-name']);
$middle_name = trim($_POST['middle-name']);
$last_name = trim($_POST['last-name']);
if($middle_name != NULL){
$full_name = $salutation . " " . $first_name . " " . $middle_name . " " . $last_name;
}else {
$full_name = $salutation . " " . $first_name . " " . $last_name;
}
$full_name = strtoupper(trim($full_name));
$email =strtolower(trim($_POST['email-address'])) ;
$course=trim($_POST['course']);
$roll = strtoupper(trim($_POST['roll']));
$reg_no = trim($_POST['reg-no']);
$registration_year=trim($_POST['registration-year']);
$department = trim($_POST['department']);
$stream = trim($_POST['stream']);
$user_type = trim($_POST['user-type']);
$password = trim($_POST['password']);
$password_hash = password_hash($password, PASSWORD_BCRYPT);
$confirm_password = trim($_POST['confirm-password']);
//Check roll number exists or not
$sql_roll_chk = "SELECT * FROM USERS where roll_no='$roll'";
$stmt_roll_chk = $pdo->prepare($sql_roll_chk);
$stmt_roll_chk->execute();
$roll_count = $stmt_roll_chk->rowCount();
//Check registration number exists or not
$sql_regno_chk = "SELECT * FROM USERS where reg_no='$reg_no'";
$stmt_regno_chk = $pdo->prepare($sql_regno_chk);
$stmt_regno_chk->execute();
$regno_count = $stmt_regno_chk->rowCount();
//Check email exists or not
$sql_email_chk = "SELECT * FROM USERS where email='$email'";
$stmt_email_chk = $pdo->prepare($sql_email_chk);
$stmt_email_chk->execute();
$email_count = $stmt_email_chk->rowCount();
if (!preg_match("/^[a-z0-9_]+@iiitkalyani\.ac\.in$/", $email, $match)){
echo "<center><strong><font color=\"red\">Email only from domain `iiitkalyani.ac.in` is allowed</font></strong></center>";
//echo "<center></br><a href=\"./signup.php\">Click Here</a> to try again</center>";
//die;
}elseif($password != $confirm_password) {
echo "<center><font color=\"red\">Password and confirm password does not match</br></font></center>";
//$error = "Password doesn't match";
}elseif ($email_count != 0){
echo "<center><font color=\"red\">Email \"" . $email . "\" already exist.</font><center>";
//die;
}elseif ($user_type=="Student" and $roll_count != 0){
echo "<center><font color=\"red\">Srudent with roll number '" . $roll . "' already exist.</font><center>";
//die;
}elseif ($user_type=="Student" and $regno_count != 0){
echo "<center><font color=\"red\">Student with registration number '" . $reg_no . "' already exist.</font><center>";
//die;
}else{
if ($user_type=="Student") {
$sql = "INSERT INTO USERS (email, course, stream, roll_no, reg_no, registration_year ,full_name, department, user_type, user_status, password,email_verified) VALUES ('$email', '$course','$stream', '$roll', '$reg_no', '$registration_year', '$full_name', '$department', '$user_type', 'Inactivated', '$password_hash','YES')";
}else{
//$sql = "INSERT INTO USERS (email, full_name, department, user_type, user_status, password) VALUES ('$email', '$full_name', '$department', '$user_type', 'Inactivated', '$password_hash')";
$sql = "INSERT INTO USERS (email, roll_no, reg_no, full_name, department, user_type, user_status, password,email_verified) VALUES ('$email', '$roll', '$roll', '$full_name', '$department', '$user_type', 'Inactivated', '$password_hash','YES')";
}
$stmt = $pdo->prepare($sql);
if ($stmt->execute())
{
echo "<center><h1>CONGRATULATIONS " . strtoupper($full_name) . " YOU HAVE BEEN SUCCESSFULLY REGISTERED</h1></br>Go to Home page to Login</center>";
}else{
echo "<center>Error in query execution</center>";
}
}
}
?>
<!--.................................Signup handelling end...............................................................-->
<form action="signup.php" method="POST">
<?php
if(isset($error)) {
echo "<p class='alert alert-danger'>{$error}</p>";
}
?>
<table align="center" border="2">
<tr style="color:purple"><td>User Type</td> <td>Student</td></tr>
<input type="hidden" name="user-type" value="Student">
<input type="hidden" name="salutation" value="None">
<tr style="color:purple"><td>First Name</td><td>
<input name="first-name" id="inputFirstName" type="text" placeholder="Enter first name" required="true" style="width: 300px;"/></td></tr>
<tr style="color:purple"><td>Middle Name</td><td>
<input name="middle-name" id="inputMiddleName" type="text" placeholder="Enter middle name" style="width: 300px;"/></td></tr>
<tr style="color:purple"><td>Last Name</td><td>
<input name="last-name" id="inputLastName" type="text" placeholder="Enter last name" style="width: 300px;"/></td></tr>
<tr style="color:purple"><td>Email</td><td>
<input name="email-address" id="inputEmailAddress" type="email" aria-describedby="emailHelp" placeholder="Enter institute email address" required="true" style="width: 300px;"/></td></tr>
<tr style="color:purple"><td>Course</td><td>
<select name="course" type="text" />
<?php
## Fetch cources
$sql = "SELECT DISTINCT course FROM AUTO_POPULATION where course!='NA'";
$stmt = $pdo->prepare($sql);
$stmt->execute();
while($var = $stmt->fetch(PDO::FETCH_ASSOC)){
//if ($var['course']!="NA") {
echo "<option value='".$var['course']."'>".$var['course']."</option>";
//}
}
?>
</select></td></tr>
<tr style="color:purple"><td>Roll No</td><td>
<input name="roll" id="inputRoll" type="text" placeholder="Enter your roll number" required="true" style="width: 300px;" minlength="5" maxlength="20" />
</br>example for PhD ECE student: PhD/ECE/20005</br>example for PhD CSE student: PhD/CSE/20005</br>example for BTech CSE student: CSE/20005</br>example for BTech ECE student: ECE/20005, Employee ID: 172033</td></tr>
<tr style="color:purple"><td>Registration No</td><td>
<input name="reg-no" id="inputRegno" type="text" placeholder="Enter your 6 digit registration number" required="true" style="width: 300px;" onkeypress="return isNumberKey(event)" maxlength="6"/></br>example: 000546</td></tr>
<tr style="color:purple"><td>Registration Year</td><td>
<select name="registration-year" id="inputRegistrationYear" type="text" required="true" />
<?php
## Fetch registration year
$sql = "SELECT DISTINCT academic_session FROM AUTO_POPULATION where academic_session!='NA' order by academic_session DESC";
$stmt = $pdo->prepare($sql);
$stmt->execute();
while($var = $stmt->fetch(PDO::FETCH_ASSOC)){
echo "<option value='".$var['academic_session']."'>".$var['academic_session']."</option>";
}
?>
</select></td></tr>
<tr style="color:purple"><td>Department</td><td>
<select name="department" id="inputDepartment" type="text" required="true" />
<?php
## Fetch department
$sql = "SELECT DISTINCT department FROM AUTO_POPULATION where department!='NA'";
$stmt = $pdo->prepare($sql);
$stmt->execute();
while($var = $stmt->fetch(PDO::FETCH_ASSOC)){
echo "<option value='".$var['department']."'>".$var['department']."</option>";
}
?>
</select>
</td></tr>
<tr style="color:purple"><td>Stream</td><td>
<select name="stream" id="inputStream" type="text" required="true" />
<?php
## Fetch stream
$sql = "SELECT DISTINCT stream FROM AUTO_POPULATION where stream!='NA'";
$stmt = $pdo->prepare($sql);
$stmt->execute();
while($var = $stmt->fetch(PDO::FETCH_ASSOC)){
echo "<option value='".$var['stream']."'>".$var['stream']."</option>";
}
?>
</select></td></tr>
<tr style="color:purple"><td>Password</td><td>
<input name="password" id="inputPassword" type="password" placeholder="Enter password" required="true" style="width: 300px;" minlength="6" maxlength="12" /></td></tr>
<tr style="color:purple"><td>Confirm Password</td><td>
<input name="confirm-password" id="inputConfirmPassword" type="password" placeholder="Confirm password" required="true" style="width: 300px;" minlength="6" maxlength="12"/></td></tr>
<tr style="color:purple"><td colspan=2 align="center">
<button name="submit" style="background-color:yellow;margin:auto;display:block;text-align:center;" type="submit">Create Account</button></td></tr>
</form>
</main>
</table>
<center>Already have an account? <a href="./index.php">Click Here</a> to Login</center>
<?php require_once("./includes/footer.php"); ?>