v5
This commit is contained in:
parent
a2059511fc
commit
082d14fa79
33
admin_dashboard.php
Normal file
33
admin_dashboard.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
if (!isset($_SESSION['user_id']) || $_SESSION['role_name'] !== 'admin') {
|
||||||
|
header('Location: login.php');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Admin Dashboard</title>
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<h1>Admin Dashboard</h1>
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<li><a href="users.php">Manage Users</a></li>
|
||||||
|
<li><a href="roles.php">Manage Roles</a></li>
|
||||||
|
<li><a href="logout.php">Logout</a></li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
<h2>Welcome, Admin!</h2>
|
||||||
|
<p>This is your dashboard. You can manage users and roles from here.</p>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
26
login.php
26
login.php
@ -29,6 +29,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$_SESSION['username'] = $username;
|
$_SESSION['username'] = $username;
|
||||||
$_SESSION['role_id'] = $user['role_id'];
|
$_SESSION['role_id'] = $user['role_id'];
|
||||||
|
|
||||||
|
// Fetch role name
|
||||||
|
$role_stmt = $db->prepare("SELECT name FROM roles WHERE id = :role_id");
|
||||||
|
$role_stmt->bindParam(':role_id', $user['role_id']);
|
||||||
|
$role_stmt->execute();
|
||||||
|
$role = $role_stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
$role_name = $role ? $role['name'] : null;
|
||||||
|
$_SESSION['role_name'] = $role_name;
|
||||||
|
|
||||||
// Log attendance
|
// Log attendance
|
||||||
$login_time = date('Y-m-d H:i:s');
|
$login_time = date('Y-m-d H:i:s');
|
||||||
$ip_address = $_SERVER['REMOTE_ADDR'];
|
$ip_address = $_SERVER['REMOTE_ADDR'];
|
||||||
@ -39,7 +47,23 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$attendance_stmt->execute();
|
$attendance_stmt->execute();
|
||||||
$_SESSION['attendance_id'] = $db->lastInsertId();
|
$_SESSION['attendance_id'] = $db->lastInsertId();
|
||||||
|
|
||||||
header("Location: index.php");
|
switch ($role_name) {
|
||||||
|
case 'admin':
|
||||||
|
header("Location: admin_dashboard.php");
|
||||||
|
break;
|
||||||
|
case 'parent':
|
||||||
|
header("Location: parent_dashboard.php");
|
||||||
|
break;
|
||||||
|
case 'student':
|
||||||
|
header("Location: student_dashboard.php");
|
||||||
|
break;
|
||||||
|
case 'teacher':
|
||||||
|
header("Location: teacher_dashboard.php");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
header("Location: index.php");
|
||||||
|
break;
|
||||||
|
}
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
$error_message = 'Invalid username or password.';
|
$error_message = 'Invalid username or password.';
|
||||||
|
|||||||
40
parent_dashboard.php
Normal file
40
parent_dashboard.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
// Authentication check
|
||||||
|
if (!isset($_SESSION['user_id']) || empty($_SESSION['role_name']) || $_SESSION['role_name'] !== 'parent') {
|
||||||
|
header('Location: login.php');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Parent Dashboard</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="p-3 mb-3 border-bottom sticky-top bg-light">
|
||||||
|
<div class="container">
|
||||||
|
<div class="d-flex flex-wrap align-items-center justify-content-center justify-content-lg-start">
|
||||||
|
<a href="/" class="d-flex align-items-center mb-2 mb-lg-0 text-dark text-decoration-none">
|
||||||
|
<span class="fs-4">School Management</span>
|
||||||
|
</a>
|
||||||
|
<ul class="nav col-12 col-lg-auto me-lg-auto mb-2 justify-content-center mb-md-0">
|
||||||
|
<li><a href="parent_dashboard.php" class="nav-link px-2 link-secondary">Dashboard</a></li>
|
||||||
|
</ul>
|
||||||
|
<div class="text-end">
|
||||||
|
<a href="logout.php" class="btn btn-outline-primary">Logout</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<main class="container py-5">
|
||||||
|
<h1>Welcome, Parent!</h1>
|
||||||
|
<p>This is your dashboard.</p>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -2,7 +2,7 @@
|
|||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
// Authentication check
|
// Authentication check
|
||||||
if (!isset($_SESSION['user_id'])) {
|
if (!isset($_SESSION['user_id']) || $_SESSION['role_name'] !== 'admin') {
|
||||||
header('Location: login.php');
|
header('Location: login.php');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|||||||
40
student_dashboard.php
Normal file
40
student_dashboard.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
// Authentication check
|
||||||
|
if (!isset($_SESSION['user_id']) || empty($_SESSION['role_name']) || $_SESSION['role_name'] !== 'student') {
|
||||||
|
header('Location: login.php');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Student Dashboard</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="p-3 mb-3 border-bottom sticky-top bg-light">
|
||||||
|
<div class="container">
|
||||||
|
<div class="d-flex flex-wrap align-items-center justify-content-center justify-content-lg-start">
|
||||||
|
<a href="/" class="d-flex align-items-center mb-2 mb-lg-0 text-dark text-decoration-none">
|
||||||
|
<span class="fs-4">School Management</span>
|
||||||
|
</a>
|
||||||
|
<ul class="nav col-12 col-lg-auto me-lg-auto mb-2 justify-content-center mb-md-0">
|
||||||
|
<li><a href="student_dashboard.php" class="nav-link px-2 link-secondary">Dashboard</a></li>
|
||||||
|
</ul>
|
||||||
|
<div class="text-end">
|
||||||
|
<a href="logout.php" class="btn btn-outline-primary">Logout</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<main class="container py-5">
|
||||||
|
<h1>Welcome, Student!</h1>
|
||||||
|
<p>This is your dashboard.</p>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
40
teacher_dashboard.php
Normal file
40
teacher_dashboard.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
// Authentication check
|
||||||
|
if (!isset($_SESSION['user_id']) || empty($_SESSION['role_name']) || $_SESSION['role_name'] !== 'teacher') {
|
||||||
|
header('Location: login.php');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Teacher Dashboard</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="p-3 mb-3 border-bottom sticky-top bg-light">
|
||||||
|
<div class="container">
|
||||||
|
<div class="d-flex flex-wrap align-items-center justify-content-center justify-content-lg-start">
|
||||||
|
<a href="/" class="d-flex align-items-center mb-2 mb-lg-0 text-dark text-decoration-none">
|
||||||
|
<span class="fs-4">School Management</span>
|
||||||
|
</a>
|
||||||
|
<ul class="nav col-12 col-lg-auto me-lg-auto mb-2 justify-content-center mb-md-0">
|
||||||
|
<li><a href="teacher_dashboard.php" class="nav-link px-2 link-secondary">Dashboard</a></li>
|
||||||
|
</ul>
|
||||||
|
<div class="text-end">
|
||||||
|
<a href="logout.php" class="btn btn-outline-primary">Logout</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<main class="container py-5">
|
||||||
|
<h1>Welcome, Teacher!</h1>
|
||||||
|
<p>This is your dashboard.</p>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -2,7 +2,7 @@
|
|||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
// Authentication check
|
// Authentication check
|
||||||
if (!isset($_SESSION['user_id'])) {
|
if (!isset($_SESSION['user_id']) || $_SESSION['role_name'] !== 'admin') {
|
||||||
header('Location: login.php');
|
header('Location: login.php');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user