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'; ?>