35595-vm/profile.php
Flatlogic Bot 89d2171b50 1.0.1
2025-11-09 14:00:35 +00:00

67 lines
2.1 KiB
PHP

<?php
require_once 'header.php';
require_once 'db/config.php';
// Check if user is logged in
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit;
}
$user_id = $_SESSION['user_id'];
$pdo = db();
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$user_id]);
$user = $stmt->fetch();
if (!$user) {
// User not found, destroy session and redirect to login
session_destroy();
header("Location: login.php");
exit;
}
?>
<header class="hero text-center">
<div class="container">
<h1 class="display-4">Welcome, <?php echo htmlspecialchars($user['username']); ?>!</h1>
<p class="lead">This is your profile page.</p>
</div>
</header>
<main class="container my-5">
<div class="row justify-content-center">
<div class="col-lg-8">
<div class="card">
<div class="card-body p-5">
<h3>Profile Information</h3>
<table class="table table-bordered">
<tr>
<th>Username</th>
<td><?php echo htmlspecialchars($user['username']); ?></td>
</tr>
<tr>
<th>Email</th>
<td><?php echo htmlspecialchars($user['email']); ?></td>
</tr>
<tr>
<th>Role</th>
<td><?php echo htmlspecialchars($user['role']); ?></td>
</tr>
<tr>
<th>Balance</th>
<td>$<?php echo htmlspecialchars(number_format($user['balance'], 2)); ?></td>
</tr>
</table>
<?php if ($user['role'] === 'admin'): ?>
<a href="admin.php" class="btn btn-primary">Admin Panel</a>
<?php endif; ?>
</div>
</div>
</div>
</div>
</main>
<?php require_once 'footer.php'; ?>