-
Notifications
You must be signed in to change notification settings - Fork 1
/
login_check.php
82 lines (69 loc) · 1.94 KB
/
login_check.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
<?php
session_start();
require('connection_db.php');
$name=$_POST["username"];
$pass=$_POST["password"];
$loginType=$_POST["login_type"];
if ($loginType == "admin") {
if ($name == "admin" && $pass == "indra") {
$_SESSION['user']=$name;
$_SESSION['pass']=$pass;
$_SESSION['login']=$loginType;
header('Location:'.$loginType.'.php');
exit();
}
else {
$_SESSION['error']="Username or Password is wrong";
header('Location:index.php');
exit();
}
}
elseif ($loginType == 'student') {
$data = "SELECT * FROM student WHERE email = '$name' and password = '$pass'";
$result = mysqli_query($connectivity, $data);
if (mysqli_num_rows($result)<=0) {
$_SESSION['n_user']= "User not found";
header('Location:index.php');
exit();
}
else{
while($row = mysqli_fetch_assoc($result)) {
$student_id=$row["student_id"];
$Nam=$row["name"];
$Email=$row["email"];
$password=$row["password"];
}
$_SESSION['login']=$loginType;
$_SESSION['name']=$Nam;
$_SESSION['email']=$Email;
$_SESSION['pass']=$password;
$_SESSION['student_id']=$student_id;
header('Location:student.php');
exit();
}
}
elseif ($loginType == 'teacher') {
$data = "SELECT * FROM teacher WHERE email = '$name' and password = '$pass'";
$result = mysqli_query($connectivity, $data);
if (mysqli_num_rows($result)<=0) {
$_SESSION['n_user']= "User not found";
header('Location:index.php');
exit();
}
else{
while($row = mysqli_fetch_assoc($result)) {
$teacher_id=$row["teacher_id"];
$Nam=$row["name"];
$Email=$row["email"];
$password=$row["password"];
}
$_SESSION['login']=$loginType;
$_SESSION['name']=$Nam;
$_SESSION['email']=$Email;
$_SESSION['pass']=$password;
$_SESSION['teacher_id']=$teacher_id;
header('Location:teacher.php');
exit();
}
}
?>