-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
148 lines (141 loc) · 4.89 KB
/
index.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
<?php include 'conn.php';
session_start();
if(isset($_SESSION['user'])){
if($_SESSION['user']=='admin'){
header('Location: Admin/dashboard.php');
}
else if($_SESSION['user']=='student'){
header('Location: Student/dashboard.php');
}
else if ($_SESSION['user']=='teacher'){
header('Location: Teacher/dashboard.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, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link href="Admin/img/logo/puc.png" rel="icon">
<title>PUC || Login Page</title>
<link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="css/ruang-admin.min.css" rel="stylesheet">
<link href="css/ruang-admin.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<style>
body {
background-color: #8fc0db;
}
form{
background-color: whitesmoke;
}
</style>
</head>
<body>
<section class="h-100">
<div class="container h-100">
<div class="row justify-content-sm-center h-100">
<div class="col-xxl-4 col-xl-5 col-lg-5 col-md-7 col-sm-9">
<form action="" method="post" class="my">
<div class="text-center my-5">
<img src="logo.png" alt="logo" width="100">
<div class="text">
<b><h3>PREMIER UNIVERSITY</h3></b>
</div>
</div>
<div class="card shadow-lg">
<div class="card-body p-4">
<h1 class="fs-4 card-title fw-bold mb-2">Login</h1>
<form method="POST" class="needs-validation" novalidate="" autocomplete="off">
<div class="mb-3">
<label class="mb-2 text-muted" for="email">E-Mail Address</label>
<input type="text" name="email" class="form-control" id="" required autofocus>
<div class="invalid-feedback">
Email is invalid
</div>
</div>
<div class="mb-3">
<div class="mb-2 w-100">
<label class="text-muted" for="password">Password</label>
</div>
<input type="password" name="password" class="form-control" id="" required>
<div class="invalid-feedback">
Password is required
</div>
</div>
<div class="d-flex align-items-center">
<div class="form-check">
<input type="checkbox" name="remember" id="remember" class="form-check-input">
<label for="remember" class="form-check-label">Remember Me</label>
</div>
<button type="submit" name="loginBtn" class="btn btn-primary ms-auto" >
Login
</button>
</div>
</form>
</div>
<div class="card-footer py-3 border-0">
<div class="text-center">
Don't have an account? <a href="admin/create_account.php" class="text-dark">Create</a>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</section>
<script src="js/login.js"></script>
</body>
</html>
<?php
if(isset($_POST['loginBtn']))
{
$email = $_POST['email'];
$password = $_POST['password'];
$query = "select * from admin_login where email='".$email."'
and password='".$password."'";
$result = mysqli_query($conn, $query);
$admin = mysqli_fetch_array($result);
$query = "select * from teacher_login where email='".$email."'
and password='".$password."'";
$result = mysqli_query($conn, $query);
$teacher = mysqli_fetch_array($result);
$query = "select * from student_login where email='".$email."'
and password='".$password."'";
$result = mysqli_query($conn, $query);
$student = mysqli_fetch_array($result);
if($admin){
// save user data into session
$_SESSION['user'] = 'admin';
$_SESSION['user_email'] = $admin['email'];
$_SESSION['user_id']=$admin['id'];
header('Location: Admin/dashboard.php');
exit();
}
else if($teacher){
// save user data into session
$_SESSION['user'] = 'teacher';
$_SESSION['user_email'] = $teacher['email'];
$_SESSION['user_id']=$teacher['id'];
header('Location: Teacher/dashboard.php');
exit();
}
else if($student){
// save user data into session
$_SESSION['user'] = 'student';
$_SESSION['user_email'] = $student['email'];
$_SESSION['user_id']=$student['id'];
header('Location: Student/dashboard.php');
exit();
}
else {?>
<div> Wrong !!! </div><?php
}
}
?>