-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprofile.php
More file actions
344 lines (320 loc) · 13.8 KB
/
Copy pathprofile.php
File metadata and controls
344 lines (320 loc) · 13.8 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
<?php
include 'auth.php';
include 'head.php';
$userID = $_SESSION['user_id'];
// Fetch employee profile information from the database
$query = "SELECT * FROM User WHERE UserID = ?";
$stmt = $con->prepare($query);
$stmt->bind_param("i", $userID);
$stmt->execute();
$result = $stmt->get_result();
$user = $result->fetch_assoc();
$stmt->close();
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_FILES['profile_image'])) {
$profileImage = $_FILES['profile_image'];
// Check for upload errors
if ($profileImage['error'] === 0) {
// Set a unique name for the file and move it to the uploads folder
$fileName = $userID . '_' . time() . '_' . basename($profileImage['name']);
$fileDestination = 'assets/images/Profile-pics/' . $fileName;
if (move_uploaded_file($profileImage['tmp_name'], $fileDestination)) {
// Update the ProfileImage in the database
$updateQuery = "UPDATE User SET ProfileImage = ? WHERE UserID = ?";
$stmt = $con->prepare($updateQuery);
$stmt->bind_param("si", $fileName, $userID);
$stmt->execute();
$stmt->close();
// Refresh the page to show the new image
header("Location: profile.php");
exit;
} else {
$error = "Failed to upload profile image.";
}
} else {
$error = "Error uploading the file.";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Profile</title>
<style>
/* Profile Picture Hover Effect */
.profile-pic-container {
position: relative;
width: 150px;
margin: auto;
transition: transform 0.3s ease-in-out;
}
.profile-pic-container:hover {
transform: scale(1.1);
}
.profile-pic-container img {
width: 150px;
height: 150px;
object-fit: cover;
border-radius: 50%;
border: 3px solid #007bff;
}
.profile-pic-container:hover .edit-overlay {
display: block;
opacity: 1;
}
.edit-overlay {
display: none;
opacity: 0;
transition: opacity 0.3s ease;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.6);
border-radius: 50%;
color: white;
font-size: 16px;
text-align: center;
padding-top: 60px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container-scroller">
<?php include 'navBar.php'; ?>
<div class="container-fluid page-body-wrapper">
<?php include 'sidebar.php'; ?>
<div class="main-panel">
<div class="content-wrapper">
<div class="page-header">
<h3 class="page-title">
<span class="page-title-icon bg-gradient-primary text-white me-2">
<i class="mdi mdi-view-list menu-icon"></i>
</span>
Profile Information
</h3>
</div>
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card shadow-lg">
<div class="card-header p-3 bg-gradient-primary text-white">
<h3 class="text-center text-uppercase font-weight-bold mt-2">
<?php echo !empty($user['FirstName']) ? htmlspecialchars($user['FirstName']) : '<span class="text-secondary">Add your First Name</span>'; ?>
<?php echo !empty($user['LastName']) ? htmlspecialchars($user['LastName']) : '<span class="text-secondary">Add your Last Name</span>'; ?>
</h3>
</div>
<div class="card-body">
<div class="text-center mb-4">
<div class="profile-pic-container">
<?php if (!empty($user['ProfileImage'])): ?>
<img src="assets/images/Profile-pics/<?php echo htmlspecialchars($user['ProfileImage']); ?>" class="rounded-circle" alt="Profile Image">
<?php else: ?>
<img src="assets/images/Profile-pics/default-profile.png" class="rounded-circle" alt="Default Profile Image">
<?php endif; ?>
<div class="edit-overlay" onclick="document.getElementById('profilePicForm').style.display='block';">
<?php echo !empty($user['ProfileImage']) ? 'Edit Profile Picture' : 'Add Profile Picture'; ?>
</div>
</div>
</div>
<!-- Profile Picture Upload Form -->
<form id="profilePicForm" method="POST" enctype="multipart/form-data" style="display:none;">
<div class="form-group">
<label for="profile_image">Choose Profile Picture</label>
<input type="file" class="form-control" name="profile_image" required>
</div>
<div class="text-center mt-3">
<button type="submit" class="btn btn-primary">Upload</button>
<button type="button" class="btn btn-secondary" onclick="document.getElementById('profilePicForm').style.display='none';">Cancel</button>
</div>
</form>
<!-- Error message if upload fails -->
<?php if (!empty($error)): ?>
<div class="alert alert-danger mt-3"><?php echo htmlspecialchars($error); ?></div>
<?php endif; ?>
<div class="row mt-4">
<!-- Username Card -->
<div class="col-md-6 col-12 mb-3">
<div class="card p-3 shadow-sm">
<div class="d-flex align-items-center">
<i class="mdi mdi-account me-3 text-primary"></i>
<div>
<h5 class="mb-0">Username</h5>
<p class="mb-0 text-secondary">
<?php echo !empty($user['Username']) ? htmlspecialchars($user['Username']) : '<span class="text-secondary">Add your Username</span>'; ?>
</p>
</div>
</div>
</div>
</div>
<!-- Email Card -->
<div class="col-md-6 col-12 mb-3">
<div class="card p-3 shadow-sm">
<div class="d-flex align-items-center">
<i class="mdi mdi-email me-3 text-primary"></i>
<div>
<h5 class="mb-0">Email</h5>
<p class="mb-0 text-secondary">
<?php echo !empty($user['Email']) ? htmlspecialchars($user['Email']) : '<span class="text-secondary">Add your Email</span>'; ?>
</p>
</div>
</div>
</div>
</div>
<!-- First Name Card -->
<div class="col-md-6 col-12 mb-3">
<div class="card p-3 shadow-sm">
<div class="d-flex align-items-center">
<i class="mdi mdi-account-circle me-3 text-primary"></i>
<div>
<h5 class="mb-0">First Name</h5>
<p class="mb-0 text-secondary">
<?php echo !empty($user['FirstName']) ? htmlspecialchars($user['FirstName']) : '<span class="text-secondary">Add your First Name</span>'; ?>
</p>
</div>
</div>
</div>
</div>
<!-- Last Name Card -->
<div class="col-md-6 col-12 mb-3">
<div class="card p-3 shadow-sm">
<div class="d-flex align-items-center">
<i class="mdi mdi-account-circle-outline me-3 text-primary"></i>
<div>
<h5 class="mb-0">Last Name</h5>
<p class="mb-0 text-secondary">
<?php echo !empty($user['LastName']) ? htmlspecialchars($user['LastName']) : '<span class="text-secondary">Add your Last Name</span>'; ?>
</p>
</div>
</div>
</div>
</div>
<!-- Phone Number Card -->
<div class="col-md-6 col-12 mb-3">
<div class="card p-3 shadow-sm">
<div class="d-flex align-items-center">
<i class="mdi mdi-phone me-3 text-primary"></i>
<div>
<h5 class="mb-0">Phone Number</h5>
<p class="mb-0 text-secondary">
<?php echo !empty($user['PhoneNumber']) ? htmlspecialchars($user['PhoneNumber']) : '<span class="text-secondary">Add your Phone Number</span>'; ?>
</p>
</div>
</div>
</div>
</div>
<!-- Address Card -->
<div class="col-md-6 col-12 mb-3">
<div class="card p-3 shadow-sm">
<div class="d-flex align-items-center">
<i class="mdi mdi-map-marker me-3 text-primary"></i>
<div>
<h5 class="mb-0">Address</h5>
<p class="mb-0 text-secondary">
<?php echo !empty($user['Address']) ? htmlspecialchars($user['Address']) : '<span class="text-secondary">Add your Address</span>'; ?>
</p>
</div>
</div>
</div>
</div>
<!-- Gender Card -->
<div class="col-md-6 col-12 mb-3">
<div class="card p-3 shadow-sm">
<div class="d-flex align-items-center">
<i class="mdi mdi-gender-male-female me-3 text-primary"></i>
<div>
<h5 class="mb-0">Gender</h5>
<p class="mb-0 text-secondary">
<?php echo !empty($user['Gender']) ? htmlspecialchars($user['Gender']) : '<span class="text-secondary">Add your Gender</span>'; ?>
</p>
</div>
</div>
</div>
</div>
<!-- Date of Birth Card -->
<div class="col-md-6 col-12 mb-3">
<div class="card p-3 shadow-sm">
<div class="d-flex align-items-center">
<i class="mdi mdi-calendar me-3 text-primary"></i>
<div>
<h5 class="mb-0">Date of Birth</h5>
<p class="mb-0 text-secondary">
<?php echo !empty($user['DateOfBirth']) ? htmlspecialchars($user['DateOfBirth']) : '<span class="text-secondary">Add your Date of Birth</span>'; ?>
</p>
</div>
</div>
</div>
</div>
<!-- Job Title Card -->
<div class="col-md-6 col-12 mb-3">
<div class="card p-3 shadow-sm">
<div class="d-flex align-items-center">
<i class="mdi mdi-briefcase me-3 text-primary"></i>
<div>
<h5 class="mb-0">Job Title</h5>
<p class="mb-0 text-secondary">
<?php echo !empty($user['JobTitle']) ? htmlspecialchars($user['JobTitle']) : '<span class="text-secondary">Add your Job Title</span>'; ?>
</p>
</div>
</div>
</div>
</div>
<!-- Department Card -->
<div class="col-md-6 col-12 mb-3">
<div class="card p-3 shadow-sm">
<div class="d-flex align-items-center">
<i class="mdi mdi-office-building me-3 text-primary"></i>
<div>
<h5 class="mb-0">Department</h5>
<p class="mb-0 text-secondary">
<?php echo !empty($user['Department']) ? htmlspecialchars($user['Department']) : '<span class="text-secondary">Add your Department</span>'; ?>
</p>
</div>
</div>
</div>
</div>
<!-- Profile Created At Card -->
<div class="col-md-6 col-12 mb-3">
<div class="card p-3 shadow-sm">
<div class="d-flex align-items-center">
<i class="mdi mdi-calendar-check me-3 text-primary"></i>
<div>
<h5 class="mb-0">Profile Created At</h5>
<p class="mb-0 text-secondary">
<?php echo !empty($user['CreatedAt']) ? htmlspecialchars($user['CreatedAt']) : '<span class="text-secondary">Not Available</span>'; ?>
</p>
</div>
</div>
</div>
</div>
<!-- Profile Last Updated Card -->
<div class="col-md-6 col-12 mb-3">
<div class="card p-3 shadow-sm">
<div class="d-flex align-items-center">
<i class="mdi mdi-calendar-edit me-3 text-primary"></i>
<div>
<h5 class="mb0">Profile Last Updated</h5>
<p class="mb-0 text-secondary">
<?php echo !empty($user['UpdatedAt']) ? htmlspecialchars($user['UpdatedAt']) : '<span class="text-secondary">Not Available</span>'; ?>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="text-center mt-4">
<a href="edit_profile.php" class="btn btn-warning"><i class="mdi mdi-pencil"></i> Edit Profile</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include 'footer.php'; ?>
</body>
</html>