35418-vm/dashboard.php
2025-11-02 14:43:46 +00:00

49 lines
1.4 KiB
PHP

<?php
require_once 'includes/header.php';
// Protect page
if (!isset($_SESSION['user_id'])) {
header('Location: index.php');
exit();
}
require_once 'db/config.php';
try {
$pdo = db();
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$_SESSION['user_id']]);
$user = $stmt->fetch();
} catch (PDOException $e) {
// Handle error, maybe redirect or show a message
$user = null;
}
?>
<div class="container">
<h1 class="mb-4">Welcome, <?php echo htmlspecialchars($user['username'] ?? 'Player'); ?>!</h1>
<div class="card bg-surface text-light p-4">
<div class="card-body">
<h2 class="card-title">Your Status</h2>
<?php if ($user): ?>
<p><strong>Level:</strong> <?php echo htmlspecialchars($user['level']); ?></p>
<p><strong>XP:</strong> <?php echo htmlspecialchars($user['xp']); ?></p>
<p><strong>Role:</strong> <?php echo htmlspecialchars(ucfirst($user['user_role'])); ?></p>
<?php else: ?>
<p class="text-danger">Could not load user data.</p>
<?php endif; ?>
</div>
</div>
<div class="mt-5">
<h3 class="text-center">Your journey continues...</h3>
<p class="text-center text-muted">Learning Kits and Achievements are coming soon!</p>
</div>
</div>
<?php
require_once 'includes/footer.php';
?>