forked from IsmailSebz/UserManagementSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php
More file actions
44 lines (38 loc) · 1.72 KB
/
profile.php
File metadata and controls
44 lines (38 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
include_once 'includes/header.php';
requireLogin();
// Get user data
$userId = $_SESSION['user_id'];
$stmt = $conn->prepare("SELECT username, email, profile_picture, created_at FROM users WHERE id = ?");
$stmt->bind_param("i", $userId);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows === 1) {
$user = $result->fetch_assoc();
} else {
$_SESSION['message'] = "Error retrieving user data";
$_SESSION['message_type'] = "error";
header("Location: index.php");
exit();
}
?>
<h2>Your Profile</h2>
<div class="profile-container">
<?php if ($user['profile_picture']): ?>
<img src="uploads/<?php echo $user['profile_picture']; ?>" alt="Profile Picture" class="profile-image">
<?php else: ?>
<div style="width: 150px; height: 150px; background-color: #ddd; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 20px;">
<span style="font-size: 50px; color: #555;"><?php echo substr($user['username'], 0, 1); ?></span>
</div>
<?php endif; ?>
<div class="profile-info">
<p><strong>Username:</strong> <?php echo $user['username']; ?></p>
<p><strong>Email:</strong> <?php echo $user['email']; ?></p>
<p><strong>Joined:</strong> <?php echo date('F j, Y', strtotime($user['created_at'])); ?></p>
</div>
<div class="profile-actions">
<a href="edit-profile.php" class="btn">Edit Profile</a>
<a href="delete-account.php" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete your account? This action cannot be undone.');">Delete Account</a>
</div>
</div>
<?php include_once 'includes/footer.php'; ?>