-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php
More file actions
81 lines (74 loc) · 2.32 KB
/
Copy pathprofile.php
File metadata and controls
81 lines (74 loc) · 2.32 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
session_start();
require 'db.php'; // Database connection script
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit();
}
$userId = $_SESSION['user_id'];
// Fetch user data
$stmt = $conn->prepare("SELECT name, email, profile_photo FROM users WHERE id = ?");
$stmt->bind_param("i", $userId);
$stmt->execute();
$result = $stmt->get_result();
$user = $result->fetch_assoc();
if ($user) {
$username = $user['name'];
$email = $user['email'];
$profilePhoto = $user['profile_photo'] ? $user['profile_photo'] : 'default-avatar.png'; // Default avatar if no photo
} else {
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>Profile</title>
<link rel="stylesheet" href="profile.css">
</head>
<body>
<header>
<a href="dashboard.php">
<h1
style="
font-size: 48px;
font-weight: 700;
margin: 0;
z-index: 2;
position: relative;
"
>
UnityHub
</h1></a>
<center>
<nav>
<a href="post-request.php">Post Request</a>
<a href="offer-help.php">Offer Help</a>
<a href="ad.html">Job</a>
<a href="profile.php">profile</a>
<a href="logout.php">Logout</a>
</nav>
</center>
</header>
<center>
<div class="profile-container">
<div class="card">
<div class="profile-photo">
<img src="<?php echo htmlspecialchars($profilePhoto); ?>" alt="Profile Photo">
</div>
<h1 class="username"><?php echo htmlspecialchars($username); ?></h1>
<p class="email"><?php echo htmlspecialchars($email); ?></p>
<a href="dashboard.php" class="btn">Back to Dashboard</a>
<form action="upload_photo.php" method="POST" enctype="multipart/form-data" class="upload-form">
<label for="profile_photo" class="file-label">Update Profile Photo</label>
<input type="file" name="profile_photo" id="profile_photo" accept="image/*">
<button type="submit" class="btn upload-btn">Upload</button>
</form>
</div>
</div>
</center>
</body>
</html>