-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php
More file actions
377 lines (352 loc) · 15.8 KB
/
profile.php
File metadata and controls
377 lines (352 loc) · 15.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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<?php
session_start();
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] != true) {
header("location: login.php");
exit;
}
@include 'config.php';
$usname = $_SESSION['username'];
$sql = "SELECT * FROM users WHERE username = '$usname'";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
$fsname = $row['fname'];
$lsname = $row['lname'];
$emails = $row['email'];
$image = $row['image'];
// Fetch user orders
$orderQuery = "SELECT * FROM orders WHERE username = '$usname'";
$orderResult = mysqli_query($conn, $orderQuery);
// Fetch user rentals
$rentalQuery = "SELECT * FROM rented WHERE username = '$usname'";
$rentalResult = mysqli_query($conn, $rentalQuery);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User Profile</title>
<link rel="stylesheet" href="style.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://kit.fontawesome.com/d01fd9c369.js" crossorigin="anonymous"></script>
<link rel="icon" type="image/png" href="image/logo.png">
<style>
body {
font-family: 'Arial', sans-serif;
background: url(wall/hero-bg.jpg) no-repeat;
margin: 0;
padding: 0;
background-size: cover;
}
.container {
max-width: 500px;
margin: 50px auto;
background-color: #1211115c;
backdrop-filter: blur(10px);
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
color: white;
}
.profile-picture {
width: 150px;
height: 150px;
border-radius: 50%;
margin-bottom: 20px;
}
.username {
font-size: 24px;
font-weight: bold;
margin-bottom: 10px;
}
.user-info {
margin-bottom: 20px;
}
.user-info div {
margin-bottom: 10px;
}
.btn-primary {
background-color: #007bff;
border: none;
}
.btn-primary:hover {
background-color: #0056b3;
}
.navbar {
background-color: #343a40;
}
.navbar .navbar-brand {
color: #fff;
}
.navbar .nav-link {
color: #fff;
}
.navbar .nav-link:hover {
color: #007bff;
}
.edit-btn {
margin-top: 20px;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="#"><i class="fa-solid fa-book"></i> Bookish!</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="inde.php"><i class="fa-solid fa-house"></i> Home</a>
</li>
<!-- Your Orders Button -->
<li class="nav-item">
<a class="nav-link" href="#" data-bs-toggle="modal" data-bs-target="#ordersModal"><i class="fa-solid fa-boxes"></i> Your Orders</a>
</li>
<!-- Your Rentals Button -->
<li class="nav-item">
<a class="nav-link" href="#" data-bs-toggle="modal" data-bs-target="#rentalsModal"><i class="fa-solid fa-key"></i> Your Rentals</a>
</li>
<!-- Your Sales Button -->
<li class="nav-item">
<a class="nav-link" href="#" data-bs-toggle="modal" data-bs-target="#salesModal"><i class="fa-solid fa-money-bill-wave"></i> Your Sales</a>
</li>
<!-- Your Custom Orders Button -->
<li class="nav-item">
<a class="nav-link" href="#" data-bs-toggle="modal" data-bs-target="#customOrdersModal"><i class="fa-solid fa-box"></i> Your Custom Orders</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<h1><i class="fa-solid fa-user"></i> User Profile</h1><br>
<?php
if ($image == NULL) {
echo '<img src="dummy.jpeg" class="profile-picture">';
} else {
echo '<img src="image/' . $image . '" class="profile-picture">';
}
?>
<div class="username"><?php echo $_SESSION['username']; ?></div>
<div class="user-info">
<div>
<label for="fname">First Name:</label>
<span id="fname"><?php echo $fsname; ?></span>
</div>
<div>
<label for="lname">Last Name:</label>
<span id="lname"><?php echo $lsname; ?></span>
</div>
<div>
<label for="email">Email:</label>
<span id="email"><?php echo $emails; ?></span>
</div>
</div>
<a class="btn btn-primary edit-btn" href="editprofile.php" role="button"><i class="fa-solid fa-pen-to-square"></i> Edit Profile</a>
<a class="btn btn-primary edit-btn" href="inde.php" role="button"><i class="fa-solid fa-backward"></i> Go Back</a>
<a class="btn btn-primary edit-btn" href="logoutt.php" role="button"><i class="fa-solid fa-heart-crack"></i> Logout</a>
</div>
<!-- Orders Modal -->
<div class="modal fade" id="ordersModal" tabindex="-1" aria-labelledby="ordersModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="ordersModalLabel">Your Orders</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table table-bordered">
<thead>
<tr>
<th>Order #</th>
<th>Item Name</th>
<th>Quantity</th>
<th>Total Amount</th>
<th>Payment Method</th>
</tr>
</thead>
<tbody>
<?php
if (mysqli_num_rows($orderResult) > 0) {
while ($orderRow = mysqli_fetch_assoc($orderResult)) {
echo "<tr>";
echo "<td>" . $orderRow['srno'] . "</td>";
echo "<td>" . $orderRow['item_name'] . "</td>";
echo "<td>" . $orderRow['qty'] . "</td>";
echo "<td>" . $orderRow['total_amount'] . "</td>";
echo "<td>" . $orderRow['payment_method'] . "</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='5'>No orders found</td></tr>";
}
?>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Rentals Modal -->
<div class="modal fade" id="rentalsModal" tabindex="-1" aria-labelledby="rentalsModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="rentalsModalLabel">Your Rentals</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table table-bordered">
<thead>
<tr>
<th>Rental #</th>
<th>Item Name</th>
<th>Rent Days</th>
<th>Total</th>
<th>Start Date</th>
<th>Return Date</th>
<th>Payment Method</th>
</tr>
</thead>
<tbody>
<?php
if (mysqli_num_rows($rentalResult) > 0) {
while ($rentalRow = mysqli_fetch_assoc($rentalResult)) {
echo "<tr>";
echo "<td>" . $rentalRow['srno'] . "</td>";
echo "<td>" . $rentalRow['item_name'] . "</td>";
echo "<td>" . $rentalRow['rent_days'] . "</td>";
echo "<td>" . $rentalRow['total'] . "</td>";
echo "<td>" . $rentalRow['start_date'] . "</td>";
echo "<td>" . $rentalRow['return_date'] . "</td>";
echo "<td>" . $rentalRow['payment_method'] . "</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='7'>No rentals found</td></tr>";
}
?>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Your Sales Modal -->
<div class="modal fade" id="salesModal" tabindex="-1" aria-labelledby="salesModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="salesModalLabel"><i class="fa-solid fa-money-bill-wave"></i> Your Sales</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table table-hover table-striped">
<thead>
<tr>
<th>#</th>
<th>Item Name</th>
<th>Category</th>
<th>Description</th>
<th>Price</th>
<th>Quantity</th>
<th>Payment Method</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<?php
$salesQuery = "SELECT * FROM sales WHERE username = '$usname'";
$salesResult = mysqli_query($conn, $salesQuery);
if (mysqli_num_rows($salesResult) > 0) {
while ($salesRow = mysqli_fetch_assoc($salesResult)) {
echo "<tr>";
echo "<td>" . $salesRow['srno'] . "</td>";
echo "<td>" . $salesRow['item_name'] . "</td>";
echo "<td>" . $salesRow['category'] . "</td>";
echo "<td>" . $salesRow['description'] . "</td>";
echo "<td>" . $salesRow['price'] . "</td>";
echo "<td>" . $salesRow['quantity'] . "</td>";
echo "<td>" . $salesRow['payment_method'] . "</td>";
echo "<td>" . $salesRow['date'] . "</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='8'>No sales found</td></tr>";
}
?>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Your Custom Orders Modal -->
<div class="modal fade" id="customOrdersModal" tabindex="-1" aria-labelledby="customOrdersModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="customOrdersModalLabel"><i class="fa-solid fa-box"></i> Your Custom Orders</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table table-hover table-striped">
<thead>
<tr>
<th>#</th>
<th>Book Name</th>
<th>Authors</th>
<th>Category</th>
<th>Quantity</th>
<th>Publisher</th>
<th>Payment Method</th>
<th>Order Date</th>
</tr>
</thead>
<tbody>
<?php
$customOrdersQuery = "SELECT * FROM custom_orders WHERE username = '$usname'";
$customOrdersResult = mysqli_query($conn, $customOrdersQuery);
if (mysqli_num_rows($customOrdersResult) > 0) {
while ($customOrdersRow = mysqli_fetch_assoc($customOrdersResult)) {
echo "<tr>";
echo "<td>" . $customOrdersRow['srno'] . "</td>";
echo "<td>" . $customOrdersRow['book_name'] . "</td>";
echo "<td>" . $customOrdersRow['authors'] . "</td>";
echo "<td>" . $customOrdersRow['category'] . "</td>";
echo "<td>" . $customOrdersRow['quantity'] . "</td>";
echo "<td>" . $customOrdersRow['publisher_name'] . "</td>";
echo "<td>" . $customOrdersRow['payment_method'] . "</td>";
echo "<td>" . $customOrdersRow['order_date'] . "</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='8'>No custom orders found</td></tr>";
}
?>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>