103 lines
4.6 KiB
PHP
103 lines
4.6 KiB
PHP
<?php
|
|
session_start();
|
|
|
|
// Check if the user is logged in
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header("Location: login.php");
|
|
exit();
|
|
}
|
|
|
|
require_once 'db/config.php';
|
|
|
|
$user = null;
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = :id");
|
|
$stmt->execute(['id' => $_SESSION['user_id']]);
|
|
$user = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
} catch (PDOException $e) {
|
|
error_log("Dashboard Page Error: " . $e->getMessage());
|
|
}
|
|
|
|
// If for some reason user is not found in DB, destroy session and redirect
|
|
if (!$user) {
|
|
session_destroy();
|
|
header("Location: login.php");
|
|
exit();
|
|
}
|
|
|
|
$projectName = 'User Dashboard';
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?php echo htmlspecialchars($projectName); ?></title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
</head>
|
|
<body>
|
|
|
|
<?php include 'partials/navbar.php'; ?>
|
|
|
|
<main class="container my-5">
|
|
<div class="row">
|
|
<!-- Sidebar -->
|
|
<div class="col-md-4">
|
|
<div class="card">
|
|
<div class="card-body text-center">
|
|
<i class="bi bi-person-circle display-3 text-primary"></i>
|
|
<h5 class="card-title mt-3"><?php echo htmlspecialchars($user['username']); ?></h5>
|
|
<p class="card-text text-muted"><?php echo htmlspecialchars($user['email']); ?></p>
|
|
<span class="badge bg-secondary"><?php echo ucfirst(htmlspecialchars($user['role'])); ?></span>
|
|
</div>
|
|
<div class="list-group list-group-flush">
|
|
<a href="dashboard.php" class="list-group-item list-group-item-action active" aria-current="true">
|
|
<i class="bi bi-person-fill-gear me-2"></i>Profile
|
|
</a>
|
|
<a href="#" class="list-group-item list-group-item-action"><i class="bi bi-journal-text me-2"></i>My Bookings</a>
|
|
<a href="#" class="list-group-item list-group-item-action"><i class="bi bi-car-front-fill me-2"></i>My Cars for Sale</a>
|
|
<a href="logout.php" class="list-group-item list-group-item-action text-danger"><i class="bi bi-box-arrow-left me-2"></i>Logout</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Main Content -->
|
|
<div class="col-md-8">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="mb-0">Welcome to your Dashboard</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<h5 class="card-title">Your Profile Information</h5>
|
|
<form>
|
|
<div class="mb-3">
|
|
<label for="username" class="form-label">Username</label>
|
|
<input type="text" class="form-control" id="username" value="<?php echo htmlspecialchars($user['username']); ?>" readonly>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="email" class="form-label">Email address</label>
|
|
<input type="email" class="form-control" id="email" value="<?php echo htmlspecialchars($user['email']); ?>" readonly>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="memberSince" class="form-label">Member Since</label>
|
|
<input type="text" class="form-control" id="memberSince" value="<?php echo date("F j, Y", strtotime($user['created_at'])); ?>" readonly>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Edit Profile (Coming Soon)</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<?php include 'partials/footer.php'; ?>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
|
</body>
|
|
</html>
|