-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheditprofiletest.php
244 lines (227 loc) · 10.4 KB
/
editprofiletest.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
<?php
include_once("./dist/php/connection.php");
session_start();
global $id;
$id=$_SESSION['user_id'];
$query = "SELECT * FROM account WHERE user_id = '$id'";
$result = $conn->query($query);
$row = $result->fetch_assoc();
$firstName = $row["First name"];
$lastName = $row["Last name"];
$email = $row["Email"];
$password = $row["Password"];
$birthdate = $row["Birth date"];
$gender = $row["Gender"];
$photo = $row["Account_picture"];
?>
<!DOCTYPE html>
<html>
<head>
<!-- metadata goes in head - Contains information that describes the web page document -->
<title>Edit Profile</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="dist/css/editprofiletest.css">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">
<script type="text/javascript" src="dist/js/editprofiletest.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
</head>
<body>
<!-- content goes in the body - contains text and elements that display in the web page document -->
<header class="p-2 mb-2 text-light" style="background-color: #0c143c">
<a href="homepage.php">
<img src="images/trolimart rect2.png" alt="TroliMart Logo" width="180" class="ml-4">
</a>
</header>
<main>
<div class="container shadow rounded pt-4 pb-4 mt-4 mb-4">
<?php
if(isset($_POST['firstName']) && isset($_POST['lastName']) && isset($_POST['emailInput']) && isset($_POST['birthdate'])) {
global $firstName, $lastName, $email, $birthdate;
$firstName = $_POST["firstName"];
$lastName = $_POST["lastName"];
$email = $_POST["emailInput"];
$password = $_POST["password"];
$newPassword = $_POST["newPassword"];
$confirmNewPassword = $_POST["confirmNewPassword"];
$birthdate = $_POST["birthdate"];
$hashedpassword = sha1($newPassword);
$sql = "SELECT Password FROM account WHERE user_id = '$id'";
$result = $conn->query($sql);
while ($row = $result->fetch_assoc()) {
$checkPassword = $row['Password'];
}
if ($id) {
$query = "UPDATE account
SET `First name` = '$firstName', `Last name` = '$lastName', `Email` = '$email',
Password = '$hashedpassword', `Birth date` = '$birthdate' WHERE user_id = '$id'";
$result = $conn->query($query);
?>
<div class="alert alert-success">Updated profile.</div>
<?php
} else {
?>
<div class="alert alert-danger">Wrong password!</div>
<?php
}
}
?>
<form class="form-container" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<h2 class='pb-4'>Edit Profile</h2>
<div class="form-row">
<div class="form-group col-md-4">
<!-- <img src="user.png" class="img img-thumbnail rounded mx-auto d-block" alt="..."> -->
<img src="images/user.png" id="profilePic"></img>
</div>
<div class="form-group col-md-8">
<h4></h4>
<p></p>
<small id="emailHelp" class="form-text text-muted pb-2"></small>
<div class="profile-pic-div">
<i class="fa fa-fw fa-camera"></i>
<input type= "file" name="photo" id= "file"value="<?php echo $row['Account_picture']; ?>" accept= "image/*" required>
<label id="editPic" for= "file"> </label>
</div>
</div>
</div>
<div class="form-group">
<label for="exampleInputEmail1">First Name</label>
<input type="text" name='firstName' class='form-control' value="<?php echo $firstName; ?>"required>
<div class="valid-feedback">
Looks good!
</div>
<div class="invalid-feedback">
Name cannot be empty.
</div>
</div>
<div class="form-group">
<label for="exampleInputEmail1">Last Name</label>
<input type="text" name='lastName' class='form-control' value="<?php echo $lastName; ?>" required>
<div class="valid-feedback">
Looks good!
</div>
<div class="invalid-feedback">
Name cannot be empty.
</div>
</div>
<div class="form-group">
<label for="birth-date">Birthday:</label>
<input type="date" class="form-control" name="birthdate" name="birthdate" value="<?php echo $birthdate; ?>"required>
<div class="valid-feedback">
Looks good!
</div>
<div class="invalid-feedback">
Birth date is invalid.
</div>
</div>
<div class="form-group pb-2">
<label for="emailInput">Email address</label>
<input type="email" class="form-control" name="emailInput" value="<?php echo $email; ?>" required>
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
<div class="valid-feedback">
Valid e-mail!
</div>
<div class="invalid-feedback">
Please provide a valid email.
</div>
</div>
<h4 class="mb-3">Change Password</h4>
<div class="form-group">
<label for="exampleInputEmail1">Current Password</label>
<input type="password" name='password' class='form-control'required>
<div class="valid-feedback">
Looks good!
</div>
</div>
<div class="form-group">
<label for="exampleInputEmail1">New Password</label>
<input type="password" name='newPassword' class='form-control'required>
<small id="passwordHelpBlock" class="form-text text-muted">
Password length must be between 8 to 10 characters with atleast one uppercase letter, one lowercase letter and one number.
</small>
<div id="validationServer03Feedback" class="invalid-feedback">
Please provide a valid password.
</div>
<div class="valid-feedback">
Looks good!
</div>
</div>
<div class="form-group">
<label for="exampleInputEmail1">Confirm New Password</label>
<input type="password" name='confirmNewPassword' class='form-control'required>
<div class="valid-feedback">
Looks good!
</div>
<div class="invalid-feedback">
Make sure both passwords match.
</div>
<button class="btn btn-success"type="submit" id="submitForm">
Save Changes
</button>
</form>
</div>
</main>
<footer class="text-center font-italic p-3 pb-4 mt-3 text-light" style="background-color: #0c143c;">
<div class="container">
<div class="row">
<div class="col-sm">
<p type="button" data-toggle="collapse" data-target="#collapseContactUs" aria-expanded="false" aria-controls="collapseExample">
<u>Contact Us</u>
</p>
<div class="collapse" id="collapseContactUs">
<div class="fs-6 fw-lighter text-left">
<ul>
<li>Call us at <p style="color:#3385ff;">03-5657 5432</p></li>
<li>Email us at <a href="mailto:[email protected]">[email protected]</a></li>
</ul>
</div>
</div>
</div>
<div class="col-sm">
<p type="button" data-toggle="collapse" data-target="#collapseAboutUs" aria-expanded="false" aria-controls="collapseExample">
<u>About Us</u>
</p>
<div class="collapse" id="collapseAboutUs">
<div class="fs-6 fw-lighter text-left">
<p>TroliMart system is intended to help the consumers to manage grocery shopping list before going to the shop to purchase the products.
</p>
</div>
</div>
</div>
<div class="col-sm">
<p type="button" data-toggle="collapse" data-target="#collapseFollowUs" aria-expanded="false" aria-controls="collapseExample">
<u>Follow Us</u>
</p>
<div class="collapse" id="collapseFollowUs">
<div class="fs-6 fw-lighter text-left">
<ul>
<li>
<nav class="navbar navbar-light">
<a class="navbar-brand text-primary" href="https://www.facebook.com/">
<img src="/images/fb.png" width="30" height="30" alt="" class="d-inline-block align-top">
Facebook
</a>
</nav>
</li>
<li>
<nav class="navbar navbar-light">
<a class="navbar-brand text-primary" href="https://www.instagram.com/">
<img src="/images/insta.jpg" width="30" height="30" alt="" class="d-inline-block align-top">
Instagram
</a>
</nav>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<p>
Copyright © 2021 TroliMart Co. <br>
</p>
</footer>
<script type="text/javascript" src="dist/js/editprofiletest.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
</body>
</html>