-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_profile.php
executable file
·314 lines (209 loc) · 8.5 KB
/
user_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
<?php
include_once "views_preprocessor.php";
// user can't view this page if they are not logged in
if (!check_session()) {
redirect_to('signup.php?msg=you must have an account here');
}
// send user an email containing a token that will last for an hour
// the token will be used as a verification code to change sensitive data
// such as password and email
// pull user details from the database except, password (allow user to enter password)
$user_email = get_user_email();
$select_user_data_query = "SELECT `users`.`user_first_name`, `users`.`user_last_name`, `users`.`user_email`, `users`.`user_bio` FROM `users` WHERE `users`.`user_email`='$user_email' LIMIT 1";
$select_user_data_result = mysqli_query($db_connection, $select_user_data_query);
if (!$select_user_data_result) {
redirect_to("index.php?msg=couldn't read your data from our system, try refreshing your page and try again later");
}
$user_data = mysqli_fetch_array($select_user_data_result);
?>
<div class="index-body container">
<div class="text-center text-info text-warning card-subtitle">
<p>Make changes and click the button to update</p>
<p>Certain information updates require further information, which would be sent to you via e-mail</p>
<p>Some changes are permanent such as deleting profile - you can not gain the articles or comment deleted</p>
<p>Because we do not keep any data of yours</p>
</div>
<div class="card card-update mx-auto mt-0">
<div class="card-header">My Account</div>
<!-- card body for first name starts here -->
<div class="card-body text-capitalize">
<!-- first name form starts here -->
<form method="POST" action="controllers/update_first_name.php" class="">
<div class="form-group">
<div class="form-row">
<div class="col-md-4">
<!-- first name -->
<div class="form-label-group">
<p class="form-control border-0" name="update_first_name" ><?=$user_data['user_first_name'];?></p>
<label for="first name" class="text-capitalize">Current First name</label>
</div>
</div>
<div class="col-md-5">
<!-- new first name -->
<div class="form-label-group">
<input type="text" class="form-control" id="last_name" name="update_first_name" placeholder="new first name" autofocus/>
<label for="new first name" class="text-capitalize">New First name</label>
</div>
</div>
<div class="col-md-2">
<!-- first name update button -->
<div class="form-label-group">
<button class="form-control-sm btn btn-primary text-capitalize" id="last_name" name="update_first_name_btn" placeholder="Last name" type="submit" >GO</button>
</div>
</div>
</div>
</div>
</form>
<!-- first name form ends here -->
</div>
<!-- card body for first name ends here -->
<hr>
<!-- card body for last name starts here -->
<div class="card-body text-capitalize">
<!-- last name form starts here -->
<form method="POST" action="controllers/update_last_name.php" class="">
<div class="form-group">
<div class="form-row">
<div class="col-md-4">
<!-- last name -->
<div class="form-label-group">
<p class="form-control border-0" name="update_last_name"><?=$user_data['user_last_name'];?></p>
<label for="last name" class="text-capitalize">Current Last name</label>
</div>
</div>
<div class="col-md-5">
<!-- new last name -->
<div class="form-label-group">
<input type="text" class="form-control" id="update_last_name" name="update_last_name" placeholder="new last name"/>
<label for="last name" class="text-capitalize">New Last name</label>
</div>
</div>
<div class="col-md-2">
<!-- last name update button -->
<div class="form-label-group">
<button class="form-control-sm btn btn-primary text-capitalize" id="update_last_name_btn" name="update_last_name_btn" type="submit" >GO</button>
</div>
</div>
</div>
</div>
</form>
<!-- last name form ends here -->
</div>
<!-- card body for last name ends here -->
<hr>
<!-- card body for bio starts here -->
<div class="card-body text-capitalize">
<!-- bio form starts here -->
<form method="POST" action="controllers/update_bio.php" class="">
<div class="form-group">
<div class="form-row">
<div class="col-md-4">
<!-- bio -->
<div class="form-label-group">
<p class="form-control border-0"><?=$user_data['user_bio'];?></p>
<label for="bio name" class="text-capitalize">Current bio</label>
</div>
</div>
<div class="col-md-5">
<!-- new bio -->
<div class="form-label-group">
<input type="text" class="form-control" id="update_bio" name="update_bio" placeholder="new bio" autofocus/>
<label for="bio" class="text-capitalize">New bio</label>
</div>
</div>
<div class="col-md-2">
<!-- bio update button -->
<div class="form-label-group">
<button class="form-control-sm btn btn-primary text-capitalize" id="update_bio_btn" name="update_bio_btn" type="submit" >GO</button>
</div>
</div>
</div>
</div>
</form>
<!-- bio form ends here -->
</div>
<!-- card body for bio ends here -->
<hr>
<!-- card body for email starts here -->
<div class="card-body text-capitalize">
<!-- email form starts here -->
<form method="POST" action="controllers/update_email.php" class="">
<div class="form-group">
<div class="form-row">
<div class="col-md-4">
<!-- email -->
<div class="form-label-group">
<p class="form-control border-0" ><?=$user_data['user_email'];?></p>
<label for="email name" class="text-capitalize">Current email</label>
</div>
</div>
<div class="col">
<!-- email update button -->
<div class="form-label-group">
<button class="form-control-sm btn btn-primary text-capitalize" id="update_email" name="update_email_btn" type="submit" >Change Email</button>
</div>
</div>
</div>
</div>
</form>
<!-- email form ends here -->
</div>
<!-- card body for email ends here -->
<hr>
<!-- card body for password starts here -->
<div class="card-body">
<!-- password form starts here -->
<form method="POST" action="controllers/update_password.php" class="">
<div class="form-group">
<div class="form-row">
<div class="col-md-4">
<!-- password -->
<div class="form-label-group">
<p class="form-control border-0">***********</p>
<label for="password name" class="text-capitalize">Current password</label>
</div>
</div>
<div class="col">
<!-- password update button -->
<div class="form-label-group">
<button class="form-control-sm btn btn-primary text-capitalize" id="update_password_btn" name="update_password_btn" type="submit" >Change Password</button>
</div>
</div>
</div>
</div>
</form>
<!-- password form ends here -->
</div>
<!-- card body for password ends here -->
<hr>
<!-- card body for delete account starts here -->
<div class="card-body">
<!-- password form starts here -->
<form method="POST" action="controllers/delete_profile_processor.php" class="">
<div class="form-group">
<div class="form-row">
<div class="col-md-3">
<!-- password -->
<div class="form-label-group">
<p class="form-control border-0">This is irreversible</p>
</div>
</div>
<div class="col-md-8">
<!-- password update button -->
<div class="form-label-group">
<button class="form-control-sm btn btn-danger text-capitalize col" id="delete_account_btn" name="delete_account_btn" type="submit" >Delete Account</button>
</div>
</div>
</div>
</div>
</form>
<!-- password form ends here -->
</div>
<!-- card body for password ends here -->
</div>
<!-- card ends here -->
</div>
<?php
/* include footer */
include_once "templates/footer.php";
?>