35106-vm/student/dashboard.php
Flatlogic Bot 9d4612b106 version2.0
2025-10-22 11:43:14 +00:00

45 lines
1.4 KiB
PHP

<?php
require_once '../includes/header.php';
require_once '../db/config.php';
if (!isset($_SESSION['id']) || $_SESSION['role'] !== 'Student') {
header('Location: ../auth/login.php');
exit;
}
$pdo = db();
$stmt = $pdo->prepare("SELECT r.room_number, r.details FROM Allocations a JOIN Rooms r ON a.room_id = r.id WHERE a.student_id = ?");
$stmt->execute([$_SESSION['id']]);
$allocation = $stmt->fetch();
?>
<div class="container mt-5">
<h1>Student Dashboard</h1>
<p>Welcome, <?php echo htmlspecialchars($_SESSION['name']); ?>!</p>
<div class="card mt-4">
<div class="card-header">
My Room Allocation
</div>
<div class="card-body">
<?php if ($allocation): ?>
<h5 class="card-title">You are allocated to Room: <?php echo htmlspecialchars($allocation['room_number']); ?></h5>
<p class="card-text"><strong>Details:</strong> <?php echo htmlspecialchars($allocation['details']); ?></p>
<?php else: ?>
<p class="card-text">You have not been allocated a room yet.</p>
<?php endif; ?>
</div>
</div>
<div class="card mt-4">
<div class="card-header">
Room Request
</div>
<div class="card-body">
<a href="request_room.php" class="btn btn-primary">Request a Room</a>
</div>
</div>
</div>
<?php require_once '../includes/footer.php'; ?>