-
Notifications
You must be signed in to change notification settings - Fork 0
/
my-account.php
379 lines (296 loc) · 13.8 KB
/
my-account.php
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
377
378
379
<?php
require "config/global.php";
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit;
}
?>
<!DOCTYPE html>
<html lang="zxx">
<head>
<title><?=page_title("Homepage"); ?></title>
<?php
include("include/head.php");
?>
</head>
<body class="blue-skin">
<!-- ============================================================== -->
<!-- Preloader - style you can find in spinners.css -->
<!-- ============================================================== -->
<!-- <div id="preloader">
<div class="preloader"><span></span><span></span></div>
</div> -->
<!-- ============================================================== -->
<!-- Main wrapper - style you can find in pages.scss -->
<!-- ============================================================== -->
<div id="main-wrapper">
<!-- ============================================================== -->
<!-- Top header -->
<!-- ============================================================== -->
<?php
include("include/header.php");
?>
<!-- ============================ Page Title Start================================== -->
<?php
include("include/page-components/my-account-header.php");
?>
<!-- ============================ Page Title End ================================== -->
<!-- ============================ User Dashboard ================================== -->
<section class="bg-light ">
<div class="container pt-5">
<div class="row">
<div class="col-lg-12 col-md-12">
<div class="filter_search_opt">
<a href="javascript:void(0);" onclick="openFilterSearch()" class="btn btn-dark full-width mb-4">Dashboard Navigation<i class="fa-solid fa-bars ms-2"></i></a>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-12">
<div class="simple-sidebar sm-sidebar" id="filter_search">
<?php
include("include/page-components/my-account-sidebar.php");
?>
</div>
</div>
<div class="col-lg-9 col-md-12">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<h4>Your Current Package: <span class="pc-title text-primary">Gold Package</span></h4>
</div>
</div>
<?php
if (isset($_SESSION['user_id'])) {
$user_id = $_SESSION['user_id'];
$queryTrash = $db->query("SELECT COUNT(*) AS count FROM ads WHERE user_id = '$user_id' AND status = 'trash'");
$trashCount = ($queryTrash && $row = $queryTrash->fetch_assoc()) ? $row['count'] : 0;
$queryPending = $db->query("SELECT COUNT(*) AS count FROM ads WHERE user_id = '$user_id' AND status = 'pending'");
$pendingCount = ($queryPending && $row = $queryPending->fetch_assoc()) ? $row['count'] : 0;
$queryActive = $db->query("SELECT COUNT(*) AS count FROM ads WHERE user_id = '$user_id' AND status = 'active'");
$activeCount = ($queryActive && $row = $queryActive->fetch_assoc()) ? $row['count'] : 0;
?>
<div class="row">
<div class="col-lg-4 col-md-6 col-sm-12">
<div class="dashboard-stat widget-1">
<div class="dashboard-stat-content">
<h4><?php echo $activeCount; ?></h4>
<span>Active Listings</span>
</div>
<div class="dashboard-stat-icon"><i class="fa-solid fa-location-dot"></i></div>
</div>
</div>
<div class="col-lg-4 col-md-6 col-sm-12">
<div class="dashboard-stat widget-2">
<div class="dashboard-stat-content">
<h4><?php echo $pendingCount; ?></h4>
<span>Pending Listings</span>
</div>
<div class="dashboard-stat-icon"><i class="ti-pie-chart"></i></div>
</div>
</div>
<div class="col-lg-4 col-md-6 col-sm-12">
<div class="dashboard-stat widget-3">
<div class="dashboard-stat-content">
<h4><?php echo $trashCount; ?></h4>
<span>Pending Listings</span>
</div>
<div class="dashboard-stat-icon"><i class="ti-user"></i></div>
</div>
</div>
</div>
<?php
}
?>
<div class="dashboard-wraper">
<!-- Basic Information -->
<?php
$msg = '';
if (isset($_SESSION['user_id'])) {
$user_id = $_SESSION['user_id'];
// Fetch user data
$query = $db->query("SELECT * FROM users WHERE id='$user_id'");
$user = mysqli_fetch_assoc($query);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Sanitize and validate form inputs
$full_name = htmlspecialchars(trim($_POST['full_name']));
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$username = htmlspecialchars(trim($_POST['username']));
$phone = htmlspecialchars(trim($_POST['phone']));
$address = htmlspecialchars(trim($_POST['address']));
$city = htmlspecialchars(trim($_POST['city']));
$state = htmlspecialchars(trim($_POST['state']));
$zip = htmlspecialchars(trim($_POST['zip']));
$about = htmlspecialchars(trim($_POST['about']));
$updated_at = date('Y-m-d H:i:s');
// Check if the email is valid
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$msg = "<div class='alert alert-danger'>Invalid email format.</div>";
} else {
// Update the users table
$stmt = $db->prepare("UPDATE users SET fname=?, name=?, phone=?, email=?, adress=?, city=?, state=?, zip=?, about=?, updated_at=? WHERE id=?");
// Check if the prepare statement was successful
if ($stmt === false) {
$msg = "<div class='alert alert-danger'>Error preparing query: " . $db->error . "</div>";
} else {
$stmt->bind_param("ssssssssssi", $full_name, $username, $phone, $email, $address, $city, $state, $zip, $about, $updated_at, $user_id);
if ($stmt->execute()) {
$msg = "<div class='alert alert-success'>Account updated successfully. <a href='my-profile.php'> View Updated Profile</a></div>";
} else {
$msg = "<div class='alert alert-danger'>Error updating user data: " . $stmt->error . "</div>";
}
// Close the statement
$stmt->close();
}
}
}
}
?>
<?= $msg ?>
<form method="post" action="">
<div class="form-submit">
<h4>My Account</h4>
<div class="submit-section">
<div class="row">
<div class="form-group col-md-6">
<label>Your Name</label>
<input type="text" class="form-control" name="full_name" value="<?= htmlspecialchars($user['fname']) ?>">
</div>
<div class="form-group col-md-6">
<label>Email</label>
<input type="email" class="form-control" name="email" value="<?= htmlspecialchars($user['email']) ?>">
</div>
<div class="form-group col-md-6">
<label>Username</label>
<input type="text" class="form-control" name="username" value="<?= htmlspecialchars($user['name']) ?>">
</div>
<div class="form-group col-md-6">
<label>Phone</label>
<input type="text" class="form-control" name="phone" value="<?= htmlspecialchars($user['phone']) ?>">
</div>
<div class="form-group col-md-6">
<label>Address</label>
<input type="text" class="form-control" name="address" value="<?= htmlspecialchars($user['adress']) ?>">
</div>
<div class="form-group col-md-6">
<label>City</label>
<input type="text" class="form-control" name="city" value="<?= htmlspecialchars($user['city']) ?>">
</div>
<div class="form-group col-md-6">
<label>State</label>
<input type="text" class="form-control" name="state" value="<?= htmlspecialchars($user['state']) ?>">
</div>
<div class="form-group col-md-6">
<label>Zip</label>
<input type="text" class="form-control" name="zip" value="<?= htmlspecialchars($user['zip']) ?>">
</div>
<div class="form-group col-md-12">
<label>About</label>
<textarea class="form-control" name="about"><?= htmlspecialchars($user['about']) ?></textarea>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary px-5 rounded">Save Changes</button>
</div>
</div>
</div>
</form>
<div id="social-form" class="form-submit" style="display:none;">
<h4>Social Accounts</h4>
<div class="submit-section">
<div class="row">
<div class="form-group col-md-6">
<label>Facebook</label>
<input type="text" name="facebook" class="form-control" value="https://facebook.com/">
</div>
<div class="form-group col-md-6">
<label>Twitter</label>
<input type="text" name="twitter" class="form-control" value="https://twitter.com/">
</div>
<div class="form-group col-md-6">
<label>Google Plus</label>
<input type="text" name="google_plus" class="form-control" value="https://googleplus.com/">
</div>
<div class="form-group col-md-6">
<label>LinkedIn</label>
<input type="text" name="linkedin" class="form-control" value="https://linkedin.com/">
</div>
<div class="form-group col-lg-12 col-md-12">
<button class="btn btn-primary rounded px-5" type="button" onclick="saveChanges()">Save Changes</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- ============================ User Dashboard End ================================== -->
<!-- ============================ Footer Start ================================== -->
<?php include("include/footer.php"); ?>
<!-- ============================ Footer End ================================== -->
<!-- Log In Modal -->
<?php include("include/loginmodal.php"); ?>
<!-- End Modal -->
<a id="back2Top" class="top-scroll" title="Back to top" href="#"><i class="ti-arrow-up"></i></a>
</div>
<!-- ============================================================== -->
<!-- End Wrapper -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- All Jquery -->
<!-- ============================================================== -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/popper.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/rangeslider.js"></script>
<script src="assets/js/select2.min.js"></script>
<script src="assets/js/jquery.magnific-popup.min.js"></script>
<script src="assets/js/slick.js"></script>
<script src="assets/js/slider-bg.js"></script>
<script src="assets/js/lightbox.js"></script>
<script src="assets/js/imagesloaded.js"></script>
<script src="assets/js/custom.js"></script>
<!-- ============================================================== -->
<!-- This page plugins -->
<!-- ============================================================== -->
<script type="text/javascript">
$(document).ready(function(){
$('.click').slick({
dots: true,
infinite: true,
speed: 300,
slidesToShow: 1,
adaptiveHeight: true
});
});
const track = document.querySelector('.carousel-track');
const slides = Array.from(track.children);
const nextButton = document.querySelector('.carousel-button.next');
const prevButton = document.querySelector('.carousel-button.prev');
const slideWidth = slides[0].getBoundingClientRect().width;
// Arrange the slides next to one another
const setSlidePosition = (slide, index) => {
slide.style.left = slideWidth * index + 'px';
};
slides.forEach(setSlidePosition);
const moveToSlide = (track, currentSlide, targetSlide) => {
track.style.transform = 'translateX(-' + targetSlide.style.left + ')';
currentSlide.classList.remove('current-slide');
targetSlide.classList.add('current-slide');
};
// When I click left, move slides to the left
prevButton.addEventListener('click', e => {
const currentSlide = track.querySelector('.current-slide');
const prevSlide = currentSlide.previousElementSibling;
moveToSlide(track, currentSlide, prevSlide);
});
// When I click right, move slides to the right
nextButton.addEventListener('click', e => {
const currentSlide = track.querySelector('.current-slide');
const nextSlide = currentSlide.nextElementSibling;
moveToSlide(track, currentSlide, nextSlide);
});
</script>
</body>
</html>