35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
require_once 'includes/header.php';
|
|
|
|
// Redirect to login page if user is not logged in
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header('Location: login.php');
|
|
exit;
|
|
}
|
|
?>
|
|
|
|
<h1>Welcome to your Learning Dashboard</h1>
|
|
<p>This is your central hub for managing your educational experience.</p>
|
|
|
|
<?php
|
|
// Example of showing different content based on role
|
|
$role = '';
|
|
try {
|
|
$stmt = db()->prepare("SELECT r.role_name FROM users u JOIN roles r ON u.role_id = r.role_id WHERE u.user_id = ?");
|
|
$stmt->execute([$_SESSION['user_id']]);
|
|
$role = $stmt->fetchColumn();
|
|
} catch (PDOException $e) {
|
|
echo "<p style='color:red'>Could not determine user role.</p>";
|
|
}
|
|
|
|
if ($role === 'admin') {
|
|
echo '<p>As an administrator, you can manage all aspects of the platform from the <a href="admin.php">Admin Dashboard</a>.</p>';
|
|
} elseif ($role === 'instructor') {
|
|
echo '<p>As an instructor, you can manage your <a href="courses.php">courses</a> and students.</p>';
|
|
} else {
|
|
echo '<p>As a student, you can view your enrolled <a href="courses.php">courses</a> and track your progress.</p>';
|
|
}
|
|
?>
|
|
|
|
<?php require_once 'includes/footer.php'; ?>
|