-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
executable file
·295 lines (295 loc) · 11.8 KB
/
signup.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
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
<?php
ob_start();
require('connect.php');
$username='';
$email='';
$password='';
$cpassword='';
$category='';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>SignUp</title>
<link rel="stylesheet" href="signupp.css">
</head>
<body>
<h1 id="title">Sign Up</h1>
<div id="form-outer">
<p id="description">
Enter the relevant details below :
</p>
<form id="signup-form" method="POST" action="signup.php">
<div class="rowTab">
<div class="labels">
<label id="username-label" for="username">User Name:<span id="required">*</span></label>
</div>
<div class="rightTab">
<input autofocus type="text" name="username" id="name" class="input-field" placeholder="Enter username" required>
</div>
</div>
<div class="rowTab">
<div class="labels">
<label id="email-label" for="email">Email:<span id="required">*</span></label>
</div>
<div class="rightTab">
<input type="email" name="email" id="email" class="input-field" required placeholder="Enter your Email">
</div>
</div>
<div class="rowTab">
<div class="labels">
<label id="password-label" for="password">Password:<span id="required">*</span></label>
</div>
<div class="rightTab">
<input type="password" name="password" id="password" class="input-field" placeholder="Enter Password">
</div>
</div>
<div class="rowTab">
<div class="labels">
<label id="cpassword-label" for="cpassword">Confirm Password:<span id="required">*</span></label>
</div>
<div class="rightTab">
<input type="password" name="cpassword" id="cpassword" class="input-field" placeholder="Enter Password Again">
</div>
</div>
<div class="rowTab">
<div class="labels">
<label for="currentPos">Which option best describes your current role?<span id="required">*</span></label>
</div>
<div class="rightTab">
<select id="dropdownForm" name="category" class="dropdown" onChange="formType()">
<option disabled value>Select an option</option>
<option value="studentFields">Student</option>
<option value="teacherFields">Teacher</option>
<option value="hubFields">Hub</option>
</select>
</div>
</div>
<div class="rowTab studentFields">
<div class="labels">
<label id="enrol-label" for="enrol">Enrolment Number:<span id="required">*</span></label>
</div>
<div class="rightTab">
<input autofocus type="text" name="enrol" id="enrol" class="input-field" placeholder="Enter enrolment number">
</div>
</div>
<div class="rowTab studentFields">
<div class="labels">
<label id="fname-label" for="fname">First Name:<span id="required">*</span></label>
</div>
<div class="rightTab">
<input autofocus type="text" name="fname" id="fname" class="input-field" placeholder="Enter First Name">
</div>
</div>
<div class="rowTab studentFields">
<div class="labels">
<label id="lname-label" for="lname">Last Name:<span id="required">*</span></label>
</div>
<div class="rightTab">
<input autofocus type="text" name="lname" id="lname" class="input-field" placeholder="Enter Last Name">
</div>
</div>
<div class="rowTab studentFields">
<div class="labels">
<label for="gender">Gender:</label>
</div>
<div class="rightTab">
<ul style="list-style: none;">
<li class="radio"><label><input name="gender-buttons" value="Male" type="radio" class="genRadio" > Male</label></li>
<li class="radio"><label><input name="gender-buttons" value="Female" type="radio" class="genRadio" > Female</label></li>
<li class="radio"><label><input name="gender-buttons" value="Other" type="radio" class="genRadio" > Other</label></li>
</ul>
</div>
</div>
<div class="rowTab studentFields">
<div class="labels">
<label id="batch-label" for="batch">Batch :</label>
</div>
<div class="rightTab">
<input autofocus type="text" name="batch" id="batch" class="input-field" placeholder="Enter Batch ">
</div>
</div>
<div class="rowTab teacherFields">
<div class="labels">
<label id="tfname-label" for="tfname">First Name:<span id="required">*</span></label>
</div>
<div class="rightTab">
<input autofocus type="text" name="tfname" id="tfname" class="input-field" placeholder="Enter First Name">
</div>
</div>
<div class="rowTab teacherFields">
<div class="labels">
<label id="tlname-label" for="tlname">Last Name:<span id="required">*</span></label>
</div>
<div class="rightTab">
<input autofocus type="text" name="tlname" id="tlname" class="input-field" placeholder="Enter Last Name">
</div>
</div>
<div class="rowTab teacherFields">
<div class="labels">
<label for="tgender">Gender:</label>
</div>
<div class="rightTab">
<ul style="list-style: none;">
<li class="radio"><label><input name="tgender" value="Male" type="radio" class="genRadio" > Male</label></li>
<li class="radio"><label><input name="tgender" value="Female" type="radio" class="genRadio" > Female</label></li>
<li class="radio"><label><input name="tgender" value="Other" type="radio" class="genRadio" > Other</label></li>
</ul>
</div>
</div>
<div class="rowTab teacherFields">
<div class="labels">
<label for="dept">Select Department:<span id="required">*</span></label>
</div>
<div class="rightTab">
<select id="deptdownForm" name="dept" class="dropdown">
<option disabled value>Select an option</option>
<option value="CSE">Computer Science</option>
<option value="ECE">Electronics and Communications</option>
<option value="MAT">Mathematics</option>
<option value="PHY">Physics</option>
<option value="HSS">Humanities and Social Science</option>
</select>
</div>
</div>
<div class="rowTab hubFields">
<div class="labels">
<label id="hubName-label" for="hubName">Hub Name:<span id="required">*</span></label>
</div>
<div class="rightTab">
<input autofocus type="text" name="hubName" id="hubName" class="input-field" placeholder="Enter Hub Name">
</div>
</div>
<div class="rowTab hubFields">
<div class="labels">
<label id="yearEst-label" for="yearEst">Founded in Year:<span id="required">*</span></label>
</div>
<div class="rightTab">
<input type="number" name="yearEst" id="yearEst" min="2001" max="2018" step="1" class="input-field" placeholder="Year" style="height: 20px">
</div>
</div>
<div class="rowTab">
<div class="labels">
<label id="pin-label" for="pin">Alternate PIN:<span id="required">*</span></label>
</div>
<div class="rightTab">
<input type="password" name="pin" id="pin" class="input-field" placeholder="Enter 6 digit PIN">
</div>
</div>
<button id="submit" type="submit">Submit</button>
</form>
</div>
<script src="signupForm.js"></script>
</body>
</html>
<?php
if($_SERVER["REQUEST_METHOD"]=="POST"){
$username=$_POST['username'];
$email=$_POST['email'];
$password=$_POST['password'];
$cpassword=$_POST['cpassword'];
$category=$_POST['category'];
$alterPin=$_POST['pin'];
if($username && $email && $password && $cpassword && $category && $alterPin){
if(preg_match("/^[a-zA-Z0-9_]*$/",$username)){
if(filter_var($email,FILTER_VALIDATE_EMAIL)){
if(strlen($alterPin)==6 && preg_match("/^[0-9]*$/",$alterPin)){
if($password==$cpassword){
$pass_md5=md5($password);
if($category=="studentFields"){
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$enrol=$_POST['enrol'];
$gender=$_POST['gender-buttons'];
$batch=$_POST['batch'];
if($batch[0]=='A'){
$course="ECE";
}
else if($batch[0]=='B'){
$course="CSE";
}
else{
$course="IT";
}
if($fname && $lname && $enrol){
if(preg_match("/^[a-zA-Z]*$/",$fname) && preg_match("/^[a-zA-Z]*$/",$lname)){
$sql="insert into userData(username,password,email,category,alterPIN) values('$username','$pass_md5','$email','$category','$alterPin')";
$sql2="insert into profileData(username,profilePic) values ('$username','https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT5k0pKpVdogRyyt06oALOEU9_cdmBCTifjoGQxnePlNbnNVzrT')";
if($conn->query($sql)){
$conn->query($sql2);
$sql1="insert into signupStudent(username,enrol,fname,lname,batch,course,gender) values('$username','$enrol','$fname','$lname','$batch','$course','$gender')";
$conn->query($sql1);
header('Location: index.php');
}
}
else{
echo"Name can only consist of alphabets";
}
}
}
else if($category=="teacherFields"){
$tfname=$_POST['tfname'];
$tlname=$_POST['tlname'];
$tgender=$_POST['tgender'];
$dept=$_POST['dept'];
if($tfname && $tlname && $tgender && $dept){
if(preg_match("/^[a-zA-Z]*$/",$tfname) && preg_match("/^[a-zA-Z]*$/",$tlname)){
$sql="insert into userData(username,password,email,category,alterPIN) values('$username','$pass_md5','$email','$category','$alterPin')";
$sql2="insert into profileData(username,profilePic) values ('$username','https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT5k0pKpVdogRyyt06oALOEU9_cdmBCTifjoGQxnePlNbnNVzrT')";
if($conn->query($sql)){
$conn->query($sql2);
$sql1="insert into signupTeacher(username,fname,lname,gender,department) values('$username','$tfname','$tlname','$tgender','$dept')";
$conn->query($sql1);
header('Location: index.php');
}
}
else{
echo"Name can only consist of alphabets";
}
}
}
else{
$hubName=$_POST['hubName'];
$yearEST=$_POST['yearEst'];
if($hubName && $yearEST){
if(preg_match("/^[a-zA-Z ]*$/",$hubName)){
$sql="insert into userData(username,password,email,category,alterPIN) values('$username','$pass_md5','$email','$category','$alterPin')";
$sql2="insert into profileData(username,profilePic) values ('$username','https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT5k0pKpVdogRyyt06oALOEU9_cdmBCTifjoGQxnePlNbnNVzrT')";
if($conn->query($sql)){
$conn->query($sql2);
$sql1="insert into signupHub(username,hubName,yearEst) values('$username','$hubName','$yearEST')";
$conn->query($sql1);
header('Location: index.php');
}
}
else{
echo"Name can only consist of alphabets";
}
}
}
}
else{
echo"passwords don't match";
}
}
else{
echo"alternate pin should have numeric value and length six";
}
}
else{
echo"enter correct email address";
}
}
else{
echo"username can only have a-z,A-Z,_,0-9";
}
}
else{
echo"please fill in all required fields";
}
}
ob_end_flush();
?>