diff --git a/admin_dashboard.php b/admin_dashboard.php
new file mode 100644
index 0000000..43f305b
--- /dev/null
+++ b/admin_dashboard.php
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+ Admin Dashboard
+
+
+
+
+ Admin Dashboard
+
+
+
+ Welcome, Admin!
+ This is your dashboard. You can manage users and roles from here.
+
+
+
\ No newline at end of file
diff --git a/login.php b/login.php
index 99512da..20c10f3 100644
--- a/login.php
+++ b/login.php
@@ -29,6 +29,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$_SESSION['username'] = $username;
$_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
$login_time = date('Y-m-d H:i:s');
$ip_address = $_SERVER['REMOTE_ADDR'];
@@ -39,7 +47,23 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$attendance_stmt->execute();
$_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();
} else {
$error_message = 'Invalid username or password.';
diff --git a/parent_dashboard.php b/parent_dashboard.php
new file mode 100644
index 0000000..71ecbea
--- /dev/null
+++ b/parent_dashboard.php
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+ Parent Dashboard
+
+
+
+
+
+ Welcome, Parent!
+ This is your dashboard.
+
+
+
diff --git a/roles.php b/roles.php
index 93fa978..480500b 100644
--- a/roles.php
+++ b/roles.php
@@ -2,7 +2,7 @@
session_start();
// Authentication check
-if (!isset($_SESSION['user_id'])) {
+if (!isset($_SESSION['user_id']) || $_SESSION['role_name'] !== 'admin') {
header('Location: login.php');
exit();
}
diff --git a/student_dashboard.php b/student_dashboard.php
new file mode 100644
index 0000000..c148d46
--- /dev/null
+++ b/student_dashboard.php
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+ Student Dashboard
+
+
+
+
+
+ Welcome, Student!
+ This is your dashboard.
+
+
+
diff --git a/teacher_dashboard.php b/teacher_dashboard.php
new file mode 100644
index 0000000..1c60275
--- /dev/null
+++ b/teacher_dashboard.php
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+ Teacher Dashboard
+
+
+
+
+
+ Welcome, Teacher!
+ This is your dashboard.
+
+
+
diff --git a/users.php b/users.php
index b3d162f..2412f87 100644
--- a/users.php
+++ b/users.php
@@ -2,7 +2,7 @@
session_start();
// Authentication check
-if (!isset($_SESSION['user_id'])) {
+if (!isset($_SESSION['user_id']) || $_SESSION['role_name'] !== 'admin') {
header('Location: login.php');
exit();
}