-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.php
366 lines (324 loc) · 19.1 KB
/
profile.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
<?php
require("backend.php");
session_start();
if (isset($_COOKIE["user"])) {
$u_id = $_COOKIE["user"];
$result = $mysqli->query("SELECT * FROM session WHERE u_id = '$u_id'");
$row = $result->fetch_assoc();
if ($row) {
$result2 = $mysqli->query("SELECT * FROM session INNER JOIN users ON session.u_id = users.id WHERE u_id = '$u_id'");
$row2 = $result2->fetch_assoc();
$_SESSION["u_name"] = $row2["uname"];
$_SESSION["u_id"] = $row2["id"];
$_SESSION["u_email"] = $row2["email"];
$_SESSION["u_type"] = $row2["utype"];
}
}
if (!$_SESSION["u_id"]) {
header("Location: login.php");
}
$link = mysqli_connect("localhost", "root", "", "postan");
if ($link === false) {
die("Connection failed: " . mysqli_connect_error());
}
$u_name = $_SESSION['u_name'];
$u_id = $_SESSION["u_id"];
$u_email = $_SESSION["u_email"];
$u_type = $_SESSION["u_type"];
$msg = '';
$success = $error = "";
if (isset($_GET["view_id"])) {
$view_id = $_GET["view_id"];
}
if (isset($_POST['updateinfo'])) {
$email = $_POST['email'];
$address = $_POST['address'];
$pno = $_POST['pno'];
if (isset($_GET["view_id"])) {
$info = mysqli_query($link, "UPDATE users SET email='$email',address='$address',pno ='$pno' WHERE id='$view_id'");
} else {
$info = mysqli_query($link, "UPDATE users SET email='$email',address='$address',pno ='$pno' WHERE id='$u_id'");
}
if (mysqli_error($link) == true) {
$msg = "<div class='alert alert-danger alert-dismissible fade show' role='alert'>
<strong>❌ Updation Failed!</strong> Email id already exist or check the input properly.
<button type='button' class='close' data-dismiss='alert' aria-label='Close'>
<span aria-hidden='true'>×</span>
</button>
</div>";
} else {
$msg = "<div class='alert alert-success alert-dismissible fade show' role='alert'>
<strong>✔ Record Updated Successfully!</strong>
<button type='button' class='close' data-dismiss='alert' aria-label='Close'>
<span aria-hidden='true'>×</span>
</button>
</div>";
}
}
if (isset($_POST["upload_dp"])) {
if (($_FILES["dp"]["size"] / 1024) < 64) {
$dp = addslashes(file_get_contents($_FILES["dp"]["tmp_name"]));
if (isset($_GET["view_id"])) {
$result = $mysqli->query("UPDATE users SET dp = '$dp' WHERE id = '$view_id'");
} else {
$result = $mysqli->query("UPDATE users SET dp = '$dp' WHERE id = '$u_id'");
}
if ($result) {
$success = "dp updated successfully!";
} else {
$error = "some error occured try again!";
}
} else {
$error = "The image size should be less than 64kb!";
}
}
if (isset($_GET["view_id"])) {
$record = mysqli_query($link, "SELECT * FROM users WHERE id = '$view_id'");
} else {
$record = mysqli_query($link, "SELECT * FROM users WHERE id = '$u_id'");
}
foreach ($record as $row) {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<script src="https://kit.fontawesome.com/22d43b373b.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="public/js/profile.js"></script>
<script type="text/javascript" src="public/js/ajax.js"></script>
<link rel="icon" href="public/images/minilogo.png" type="image/x-icon">
<link rel="stylesheet" href="public/css/profile.css">
<link rel="stylesheet" href="public/css/chatbot.css">
<script type="text/javascript" src="public/js/chatbot.js"></script>
</head>
<title>Postan | <?php echo $u_name; ?></title>
<body>
<!-- navbar -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark sticky-top" style="background-color: black !important; border-bottom:3px solid #ffcc00;">
<img src="public/images/logo.PNG" alt="company logo" height="40px"><span><a class="nav-link" href="index.php" style="font-family: Century Gothic; font-size: 25px; color: #ffcc00">Postan<span class="sr-only">(current)</span></a>
</span>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-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 mr-auto">
<li class="nav-item">
<a class="nav-link" id="link" href="index.php">Home</a>
</li>
<?php if ($u_type == "Customer") { ?>
<li class="nav-item">
<a class="nav-link" id="link" href="courier.php">Courier</a>
</li>
<?php } ?>
<li class="nav-item">
<a class="nav-link" id="link" href="dashboard.php">Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link" id="link" href="aboutus.php">About Us</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="profile.php" id="link" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class='fas fa-user-circle'></i> <?php echo $u_name; ?>
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: black">
<a class="dropdown-item text-light" href="profile.php">Profile page</a>
<a class="dropdown-item text-light" href="history.php">History</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-light" href="logout.php">Logout</a>
</div>
</li>
</ul>
<form class="form-inline my-2 my-lg-0 dropdown">
<input class="form-control mr-sm-2" id="search_text" type="search" placeholder="Search Courier" aria-label="Search">
<div class="dropdown-content" id="result"></div>
</form>
</div>
</nav>
<div class="container">
<h1 style="margin-top: 30px;"><kbd style="color: #ffcc00; background-color:black; font-family: Century Gothic; border-radius: 10px;">Hello</kbd> <?php echo $row['utype']; ?></h1>
<div class="container" style="margin-top: 25px; margin-bottom: 50px;">
<?php if ($success) { ?>
<div class="alert alert-success alert-dismissible font-weight-bold fade show mb-3" role="alert">
<?php
echo $success;
?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<?php } elseif ($error) { ?>
<div class="alert alert-danger alert-dismissible font-weight-bold fade show mb-3" role="alert">
<?php
echo $error;
?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<?php } ?>
<?php echo $msg; ?>
<div class="row no-gutters jumbotron">
<div class="col-md-4" style="max-width: 300px; max-height: 300px;">
<?php if ($row["dp"]) {
echo "<center><img src='data:image/jpeg;base64," . base64_encode($row["dp"]) . "' alt='User dp' id='pic' class='card-img fas fa-user pcard'></center>";
} else { ?>
<center><img src="public/images/avatar.jpg" id="pic" class='card-img fas fa-user pcard'></img></center>
<?php } ?>
<?php if ($u_id == $row["id"]) { ?>
<a href="#" id="edit" onclick="openForm1()" style="overflow: hidden; position:absolute; bottom: 0px;right: 0px;" title="Upload dp"><i class='material-icons' id="ch">add_circle</i></a>
<?php } ?>
<div class="form-group form-popup-dp" id="updatedp">
<form action="" method="POST" class="form-container-dp" enctype="multipart/form-data">
<label for="dp">
<h5 style="border-bottom: 1px solid #ffcc00; color: white;">Profile Picture:</h5>
</label><br>
<input type="file" name="dp" class="form-control-file" id="dp" required><br>
<input type="submit" name="upload_dp" class="btn btn-sm btn-primary" value="Update" id="dpbtn">
<input type="button" class="btn btn-sm btn-danger cancel" value="Cancel" onclick="closeForm1()">
</form>
</div>
</div>
<div class="col-md-8">
<div class="card-body">
<h1 class="display-4" style="color: black;"><?php echo $row["uname"]; ?></h1>
<?php if ($u_id == $row["id"]) { ?>
<a href="#" onclick="openForm2()" style="overflow: hidden; position: absolute; top: 10px;right: 0px;" title="Edit"><i class='fa fa-cog' id="ch"></i></a>
<?php } ?>
<div class="form-group form-popup-info" id="updateinfo">
<form action="" method="POST" class="form-container-info">
<label for="exampleFormControlFile1">
<h5 style="border-bottom: 1px solid #ffcc00; color: white;">Edit your Profile Information here.</h5>
</label><br>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" value="<?php echo $row['email']; ?>" class="form-control" id="email" name="email" placeholder="Email" autocomplete="off">
<small id="emailHelp" class="form-text text-muted">Email id will update only if it's unique.</small>
</div>
<div class="form-group">
<label for="add" class="change">Address</label>
<textarea class="form-control" id="add" placeholder="Address" name="address" required id="in-between"><?php echo $row['address']; ?></textarea>
<small id="emailHelp" class="form-text text-muted">Address can't contain quotes.</small>
</div>
<div class="form-group">
<label for="phone" class="change">Phone No</label>
<input type="tel" value="<?php echo $row['pno']; ?>" class="form-control" id="tel" placeholder="Phone Number" name="pno" required id="in-between">
</div>
<input type="submit" class="btn btn-sm btn-primary" name="updateinfo" value="Update">
<input type="button" class="btn btn-sm btn-danger cancel" value="Cancel" onclick="closeForm2()">
</form>
</div>
<p class="lead"><?php echo $row['address']; ?></p>
<hr class="my-4">
<p>Email: <?php echo $row['email']; ?><br>Phone No: <?php echo $row['pno'];
} ?></p>
<p class="card-text"><small class="text-muted">To view Profile picture Hover over avtar.</small></p>
</div>
</div>
</div>
</div>
</div>
<!-- footer -->
<footer class="page-footer font-small" style="background-color: black; border-top: 2px solid #ffcc00;">
<div class="container">
<div class="row text-center d-flex justify-content-center pt-5 mb-3">
<div class="col-md-2 mb-3">
<h6 class="text-uppercase font-weight-bold">
<a href="index.php" id="primarycolor">Home</a>
</h6>
</div>
<?php if ($u_type == "Customer") { ?>
<div class="col-md-2 mb-3">
<h6 class="text-uppercase font-weight-bold">
<a href="courier.php" id="primarycolor">Courier</a>
</h6>
</div>
<?php } ?>
<div class="col-md-2 mb-3">
<h6 class="text-uppercase font-weight-bold">
<a href="dashboard.php" id="primarycolor">Dashboard</a>
</h6>
</div>
<div class="col-md-2 mb-3">
<h6 class="text-uppercase font-weight-bold">
<a href="aboutus.php" id="primarycolor">About Us</a>
</h6>
</div>
<div class="col-md-2 mb-3">
<h6 class="text-uppercase font-weight-bold">
<a href="profile.php" id="primarycolor">Profile</a>
</h6>
</div>
</div>
<hr class="rgba-white-light bg-light" style="margin: 0 15%;">
<div class="row d-flex text-center justify-content-center mb-md-0 mb-4">
<div class="col-md-8 col-12 mt-5 text-light">
<p style="line-height: 1.7rem; text-align: justify;"> Postan is a courier management service used
by multiple courier companies, we provide
secure and
reliable online services, so that company can operate smoothly. Place your courier now! and leave the rest to us.
what are you waiting for? we provide the best
services
and the best prices, let our delivery boy take care of packaging and delivering courier safely!
</p>
</div>
</div>
<hr class="clearfix d-md-none rgba-white-light" style="margin: 10% 15% 5%;">
<div class="row">
<div class="col-md-12">
<div class="mb-2 flex-center text-center text-light">
<a href="" class="text-decoration-none">
<i class="fab fa-facebook-f fa-lg mr-4 text" id="socialicon"> </i>
</a>
<a href="" class="text-decoration-none">
<i class="fab fa-twitter fa-lg mr-4" id="socialicon"> </i>
</a>
<a href="" class="text-decoration-none">
<i class="fab fa-google-plus-g fa-lg mr-4" id="socialicon"> </i>
</a>
<a href="" class="text-decoration-none">
<i class="fab fa-linkedin-in fa-lg mr-4" id="socialicon"> </i>
</a>
<a href="" class="text-decoration-none">
<i class="fab fa-instagram fa-lg mr-4" id="socialicon"> </i>
</a>
<a href="" class="text-decoration-none">
<i class="fab fa-pinterest fa-lg mr-4" id="socialicon"> </i>
</a>
</div>
</div>
</div>
</div>
<div class="footer-copyright text-center py-3 text-light">
© 2020 Copyright:
<a href="index.php">Postan.com</a>
</div>
</footer>
<div>
<a href="#" onclick="openForm()" style="box-shadow: 0px 8px 16px 0px rgba(0,0,0,1); overflow: hidden; position:fixed; bottom: 20px; right: 20px; background-color: black; border-radius: 10px; z-index: 10;" class="animate3" id="cb"><i class='fas fa-user-astronaut p-2 animate3' id="cb"></i></a>
<div class="form-group form-popup-chatbot" id="chatbot">
<form name="botform" method="post" class="form-container-chatbot animate">
<center><label for="exampleFormControlFile1">
<h5 style='font-size:24px; color: #ffcc00;'><i class='fas fa-user-astronaut' style='font-size:25px; color: #ffcc00;'></i> STANBOT</h5><small id="emailHelp" class="form-text text-muted">Encryption by Team Postan</small>
<div class='dropdown-divider'></div>
<h6 style="color: white;">Hello, how can i help you ?</h6>
</label></center>
<div class="botmsg animate2">
<p style="color:black;" id="bot"></p>
</div>
<input class="form-control mb-2" type="text" name="mytext" id="u_msg" placeholder="Type a message" onfocus="this.value=''" autocomplete="off" required>
<div class="form-inline">
<button class="btn btn-success mx-2" id="send" onclick="window.onclick(reply())" onclick="document.botform.mytext.focus();">Send</button></br>
<input type="button" class="btn btn-sm btn-danger mb-2" value="Cancel" onclick="closeForm()">
<input type="checkbox" oninvalid="this.setCustomValidity('IGNORE THIS')" required>
</div>
</form>
</div>
</div>
</body>
</html>