-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
341 lines (299 loc) · 12.9 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
<?php
session_start();
if(!isset($_SESSION['user_id'])){
header("location: index.php");
}
include('connection.php');
$user_id = $_SESSION['user_id'];
//get username and email
$sql = "SELECT * FROM users WHERE user_id='$user_id'";
$result = mysqli_query($link, $sql);
$count = mysqli_num_rows($result);
if($count == 1){
$row = $result -> fetch_array(MYSQLI_ASSOC);
$username = $row['username'];
$email = $row['email'];
$picture = $row['profilepicture'];
}else{
echo "There was an error retrieving the username and email from the database";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Profile</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="styling.css" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Arvo' rel='stylesheet' type='text/css'>
<style>
#container{
margin-top:100px;
}
#notePad, #allNotes, #done{
display: none;
}
.buttons{
margin-bottom: 20px;
}
textarea{
width: 100%;
max-width: 100%;
font-size: 16px;
line-height: 1.5em;
border-left-width: 20px;
border-color: #CA3DD9;
color: #CA3DD9;
background-color: #FBEFFF;
padding: 10px;
}
tr{
cursor: pointer;
}
#previewing{
max-width: 100%;
height: auto;
border-radius: 50%;
}
.previewing2{
margin: auto;
height: 20px;
border-radius: 50%;
}
#spinner{
display: none;
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
height: 85px;
text-align: center;
margin: auto;
z-index: 1100;
}
</style>
</head>
<body>
<!--Navigation Bar-->
<nav role="navigation" class="navbar navbar-custom navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand">Car Sharing</a>
<button type="button" class="navbar-toggle" data-target="#navbarCollapse" data-toggle="collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="navbarCollapse">
<ul class="nav navbar-nav">
<li><a href="index.php">Search</a></li>
<li class="active"><a href="#">Profile</a></li>
<li><a href="#">Help</a></li>
<li><a href="#">Contact us</a></li>
<li><a href="mainpageloggedin.php">My Trips</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">
<?php
if(empty($picture)){
echo "<div class='image_preview' data-target='#updatepicture' data-toggle='modal'><img class='previewing2' src='profilepicture/noimage.jpg' /></div>";
}else{
echo "<div class='image_preview' data-target='#updatepicture' data-toggle='modal'><img class='previewing2' src='$picture' /></div>";
}
?>
</a>
</li>
<li><a href="#"><b><?php echo $username ?></b></a></li>
<li><a href="index.php?logout=1">Log out</a></li>
</ul>
</div>
</div>
</nav>
<!--Container-->
<div class="container" id="container">
<div class="row">
<div class="col-md-offset-3 col-md-6">
<h2>General Account Settings:</h2>
<div class="table-responsive">
<table class="table table-hover table-condensed table-bordered">
<tr data-target="#updateusername" data-toggle="modal">
<td>Username</td>
<td><?php echo $username ?></td>
</tr>
<tr data-target="#updateemail" data-toggle="modal">
<td>Email</td>
<td><?php echo $email ?></td>
</tr>
<tr data-target="#updatepassword" data-toggle="modal">
<td>Password</td>
<td>hidden</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<!--Update username-->
<form method="post" id="updateusernameform">
<div class="modal" id="updateusername" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">
×
</button>
<h4 id="myModalLabel">
Edit Username:
</h4>
</div>
<div class="modal-body">
<!--update username message from PHP file-->
<div id="updateusernamemessage"></div>
<div class="form-group">
<label for="username" >Username:</label>
<input class="form-control" type="text" name="username" id="username" maxlength="30" value="<?php echo $username; ?>">
</div>
</div>
<div class="modal-footer">
<input class="btn green" name="updateusername" type="submit" value="Submit">
<button type="button" class="btn btn-default" data-dismiss="modal">
Cancel
</button>
</div>
</div>
</div>
</div>
</form>
<!--Update email-->
<form method="post" id="updateemailform">
<div class="modal" id="updateemail" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">
×
</button>
<h4 id="myModalLabel">
Enter new email:
</h4>
</div>
<div class="modal-body">
<!--Update email message from PHP file-->
<div id="updateemailmessage"></div>
<div class="form-group">
<label for="email" >Email:</label>
<input class="form-control" type="email" name="email" id="email" maxlength="50" value="<?php echo $email ?>">
</div>
</div>
<div class="modal-footer">
<input class="btn green" name="updateusername" type="submit" value="Submit">
<button type="button" class="btn btn-default" data-dismiss="modal">
Cancel
</button>
</div>
</div>
</div>
</div>
</form>
<!--Update password-->
<form method="post" id="updatepasswordform">
<div class="modal" id="updatepassword" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">
×
</button>
<h4 id="myModalLabel">
Enter Current and New password:
</h4>
</div>
<div class="modal-body">
<!--Update password message from PHP file-->
<div id="updatepasswordmessage"></div>
<div class="form-group">
<label for="currentpassword" class="sr-only" >Your Current Password:</label>
<input class="form-control" type="password" name="currentpassword" id="currentpassword" maxlength="30" placeholder="Your Current Password">
</div>
<div class="form-group">
<label for="password" class="sr-only" >Choose a password:</label>
<input class="form-control" type="password" name="password" id="password" maxlength="30" placeholder="Choose a password">
</div>
<div class="form-group">
<label for="password2" class="sr-only" >Confirm password:</label>
<input class="form-control" type="password" name="password2" id="password2" maxlength="30" placeholder="Confirm password">
</div>
</div>
<div class="modal-footer">
<input class="btn green" name="updateusername" type="submit" value="Submit">
<button type="button" class="btn btn-default" data-dismiss="modal">
Cancel
</button>
</div>
</div>
</div>
</div>
</form>
<!--Update picture-->
<form method="post" enctype="multipart/form-data" id="updatepictureform">
<div class="modal" id="updatepicture" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">
×
</button>
<h4 id="myModalLabel">
Upload Picture:
</h4>
</div>
<div class="modal-body">
<!--Update picture message from PHP file-->
<div id="updatepicturemessage"></div>
<?php
if(empty($picture)){
echo "<div class='image_preview'><img id='previewing' src='profilepicture/noimage.jpg' /></div>";
}else{
echo "<div class='image_preview'><img id='previewing' src='$picture' /></div>";
}
?>
<div class="form-inline">
<div class="form-group">
<label for="picture">Select a picture:</label>
<input type="file" name="picture" id="picture">
</div>
</div>
</div>
<div class="modal-footer">
<input class="btn green" name="updatepicture" type="submit" value="Submit">
<button type="button" class="btn btn-default" data-dismiss="modal">
Cancel
</button>
</div>
</div>
</div>
</div>
</form>
<!-- Footer-->
<div class="footer">
<div class="container">
<p>DevelopmentIsland.com Copyright © 2015-<?php $today = date("Y"); echo $today?>.</p>
</div>
</div>
<!--Spinner-->
<div id="spinner">
<img src='ajax-loader.gif' width="64" height="64" />
<br>Loading..
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<script src="profile.js"></script>
</body>
</html>