-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.php
More file actions
31 lines (28 loc) · 827 Bytes
/
dashboard.php
File metadata and controls
31 lines (28 loc) · 827 Bytes
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
<?php
session_start();
include('config.php');
$email = $_POST['email'];
$password = $_POST['password'];
$query = "SELECT * FROM users WHERE email=?";
$stmt = $conn->prepare($query);
$stmt->bind_param("s", $email);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows == 1) {
$user = $result->fetch_assoc();
if (password_verify($password, $user['password'])) {
$_SESSION['user'] = $user;
if ($user['role'] == 'admin') {
header("Location: admin/dashboard.php");
} elseif ($user['role'] == 'staff') {
header("Location: staff/dashboard.php");
} else {
header("Location: student/dashboard.php");
}
} else {
echo "Invalid Credentials!";
}
} else {
echo "User not found!";
}
?>