You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
FutureCraft/dashboard.php

90 lines
2.8 KiB

<?php
require 'db_connection.php';
session_start();
// Check if the user is logged in
if (!isset($_SESSION['user_email'])) {
header("Location: login.php");
exit;
}
// Get user details from the session
$user_email = $_SESSION['user_email'];
// Fetch user information from the database
$stmt = $conn->prepare("SELECT * FROM users WHERE email = ?");
$stmt->bind_param("s", $user_email);
echo"$user_email";
$stmt->execute();
$result = $stmt->get_result();
$user = $result->fetch_assoc();
if (!$user) {
echo "User not found.";
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User Dashboard</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
</head>
<body>
<?php include 'includes/header.php'; ?>
<div class="container mt-5">
<h1>Welcome, <?= htmlspecialchars($user['first_name']) ?>!</h1>
<p>You are logged in as: <strong><?= htmlspecialchars($user['role']) ?></strong></p>
<hr>
<h3>Your Details</h3>
<table class="table table-bordered">
<tr>
<th>Email</th>
<td><?= htmlspecialchars($user['email']) ?></td>
</tr>
<tr>
<th>First Name</th>
<td><?= htmlspecialchars($user['first_name']) ?></td>
</tr>
<tr>
<th>Last Name</th>
<td><?= htmlspecialchars($user['last_name']) ?></td>
</tr>
<tr>
<th>Phone</th>
<td><?= htmlspecialchars($user['phone']) ?></td>
</tr>
<tr>
<th>Role</th>
<td><?= htmlspecialchars($user['role']) ?></td>
</tr>
<tr>
<th>Account Created</th>
<td><?= htmlspecialchars($user['created_at']) ?></td>
</tr>
</table>
<hr>
<h3>Quick Actions</h3>
<div class="d-flex gap-3">
<?php if ($user['role'] === 'donor'): ?>
<a href="donate_material.php" class="btn btn-primary">Donate Material</a>
<a href="donate_monetary.php" class="btn btn-success">Donate Money</a>
<a href="donor_profile.php" class="btn btn-danger">Donate Blood</a>
<?php elseif ($user['role'] === 'recipient'): ?>
<a href="view_donations.php" class="btn btn-info">View Available Donations</a>
<a href="submit_request.php" class="btn btn-warning">Submit a Request</a>
<?php elseif ($user['role'] === 'admin'): ?>
<a href="admin_dashboard.php" class="btn btn-secondary">Admin Dashboard</a>
<?php endif; ?>
</div>
</div>
</body>
</html>