46 lines
1.5 KiB
PHP
46 lines
1.5 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_no, r.type, r.block 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_no']); ?></h5>
|
|
<p class="card-text"><strong>Type:</strong> <?php echo htmlspecialchars($allocation['type']); ?></p>
|
|
<p class="card-text"><strong>Block:</strong> <?php echo htmlspecialchars($allocation['block']); ?></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'; ?>
|