-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathregistration.php
More file actions
403 lines (330 loc) · 10.8 KB
/
registration.php
File metadata and controls
403 lines (330 loc) · 10.8 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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
<?php
session_start();
include('connect.php');
?>
<!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">
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background-image: url('https://wallpaperaccess.com/full/2785178.jpg');
}
.container {
position: relative;
max-width: 900px;
width: 100%;
border-radius: 6px;
padding: 30px;
margin: 0 15px;
background-color: white;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}
.container header {
position: relative;
font-size: 20px;
font-weight: 600;
color: #333;
}
.container header::before {
content: "";
position: absolute;
left: 0;
bottom: -2px;
height: 3px;
width: 27px;
border-radius: 8px;
background-color: #4070f4;
}
.container form {
position: relative;
margin-top: 16px;
min-height: 490px;
background-color: #fff;
overflow: hidden;
}
.container form .form {
position: absolute;
background-color: #fff;
transition: 0.3s ease;
}
.container form .form.second {
opacity: 0;
pointer-events: none;
transform: translateX(100%);
}
form.secActive .form.second {
opacity: 1;
pointer-events: auto;
transform: translateX(0);
}
form.secActive .form.first {
opacity: 0;
pointer-events: none;
transform: translateX(-100%);
}
.container form .title {
display: block;
margin-bottom: 8px;
font-size: 16px;
font-weight: 500;
margin: 6px 0;
color: #333;
}
.container form .fields {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
}
form .fields .input-field {
display: flex;
width: calc(100% / 3 - 15px);
flex-direction: column;
margin: 4px 0;
}
.input-field label {
font-size: 12px;
font-weight: 500;
color: #2e2e2e;
}
.input-field input,
select {
outline: none;
font-size: 14px;
font-weight: 400;
color: #333;
border-radius: 5px;
border: 1px solid #aaa;
padding: 0 15px;
height: 42px;
margin: 8px 0;
}
.input-field input :focus,
.input-field select:focus {
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.13);
}
.input-field select,
.input-field input[type="date"] {
color: #707070;
}
.input-field input[type="date"]:valid {
color: #333;
}
.container form button,
.backBtn {
display: flex;
align-items: center;
justify-content: center;
height: 45px;
max-width: 200px;
width: 100%;
border: none;
outline: none;
color: #fff;
border-radius: 5px;
margin: 25px 0;
background-color: #4070f4;
transition: all 0.3s linear;
cursor: pointer;
}
.container form .btnText {
font-size: 14px;
font-weight: 400;
}
form button:hover {
background-color: #265df2;
}
.nextBtn {
background-color: #265df2;
margin: 0 6px;
margin-right: 14px;
display: flex;
align-items: center;
justify-content: center;
height: 45px;
max-width: 200px;
width: 100%;
border: none;
outline: none;
color: #fff;
border-radius: 5px;
margin: 25px 0;
background-color: #4070f4;
transition: all 0.3s linear;
cursor: pointer;
}
.nextBtn:hover {
background-color: #7453ce;
}
form button i,
form .backBtn i {
margin: 0 6px;
}
form .backBtn i {
transform: rotate(180deg);
}
form .buttons {
display: flex;
align-items: center;
}
form .buttons button,
.backBtn {
margin-right: 14px;
}
@media (max-width: 750px) {
.container form {
overflow-y: scroll;
}
.container form::-webkit-scrollbar {
display: none;
}
form .fields .input-field {
width: calc(100% / 2 - 15px);
}
}
@media (max-width: 550px) {
form .fields .input-field {
width: 100%;
}
}
</style>
<title>Regisration</title>
</head>
<body>
<div class="container">
<header>Registration</header>
<form action="registration.php" method="post">
<div class="form first">
<div class="details personal">
<span class="title">Personal Details</span>
<div class="fields">
<div class="input-field">
<label>Name</label>
<input type="text" name="user" placeholder="Enter your name" required>
</div>
<div class="input-field">
<label>Email</label>
<input type="email" name="mail" placeholder="Enter your email" required>
</div>
<div class="input-field">
<label>Register As</label>
<select name="role" required>
<option disabled selected>Select</option>
<option>student</option>
<option>teacher</option>
</select>
</div>
<div class="input-field">
<label>Password</label>
<input type="password" name="pass" placeholder="Enter password" required>
</div>
<div class="input-field">
<label>Conform Password</label>
<input type="password" name="conf" placeholder="Conform password" required>
</div>
<div class="input-field">
<label>Mobile Number</label>
<!-- <input type="number" name="phone" placeholder="Enter mobile number" required> -->
<input type="tel" id="phone" name="phone" placeholder="01XXXXXXXXX"
pattern="[0]{1}[1]{1}[0-9]{9}">
</div>
<div class="input-field">
<label>Gender</label>
<select name="gender" required>
<option disabled selected>Select gender</option>
<option>Male</option>
<option>Female</option>
</select>
</div>
<input type="submit" class="nextBtn" name="submit" value="Register" />
</div>
</div>
</form>
</div>
<?php
if(isset($_POST['submit']))
{
if($_POST['pass'] == $_POST['conf']){
$username = $_POST['user'];
$password = $_POST['pass'];
$email = $_POST['mail'];
$gen = $_POST['gender'];
$phone = $_POST['phone'];
$role = $_POST['role'];
$sql = "select *from $role where Mail = '$email'";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
$count = mysqli_num_rows($result);
if($count == 1){
echo "<h1><center> User Already Exist </center></h1>";
}
else{
if($role == 'student'){
$sql = "INSERT INTO student (S_ID, Name, Mail, Gender, Pass) VALUES (NULL, '$username', '$email', '$gen', '$password');";
$result = mysqli_query($conn, $sql);
$sql = "select *from student where Mail = '$email' and Pass = '$password'";
$result = mysqli_query($conn , $sql);
$count = mysqli_num_rows($result);
$row = $result->fetch_assoc();
if($count==1)
{
$_SESSION['userID'] = $row['S_ID'];
$_SESSION['password'] = $row['Pass'];
$_SESSION['mail'] = $row['Mail'];
$_SESSION['name'] = $row['Name'];
echo "<script>window.location.href='studentProfile2.php'</script>";
}
else
{
echo "<h1><center></center> Login failed. Invalid username or password.</h1>";
}
}
else if($role == 'teacher'){
$sql = "INSERT INTO teacher (T_ID, Name, Mail, Ph_No, Specialization, Pass, status) VALUES (NULL, '$username', '$email', '$phone', NULL, '$password', 'unverified');";
$result = mysqli_query($conn, $sql);
$sql = "select *from teacher where Mail = '$email'";
$result = mysqli_query($conn , $sql);
$count = mysqli_num_rows($result);
$row = $result->fetch_assoc();
if($count==1)
{
$_SESSION['teacherID'] = $row['T_ID'];
$_SESSION['password'] = $row['Pass'];
$_SESSION['mail'] = $row['Mail'];
$_SESSION['name'] = $row['Name'];
$_SESSION['status'] = $row['status'];
echo "<script>window.location.href='verification.php'</script>";
}
else
{
echo "<h1><center></center> Login failed. Invalid username or password.</h1>";
}
$conn->close();
}
}
}
else{
?>
<script>
alert("Passwords do not match. Please try again")
</script>
<?php
}
}
?>
</body>
</html>