-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforgetpassword.php
More file actions
301 lines (259 loc) · 7.32 KB
/
Copy pathforgetpassword.php
File metadata and controls
301 lines (259 loc) · 7.32 KB
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
<?php
include 'connect.php';
if(isset($_POST['submit'])){
$email = mysqli_real_escape_string($conn, $_POST['email']);
$phoneNumber = mysqli_real_escape_string($conn, $_POST['phone']);
$password = mysqli_real_escape_string($conn, $_POST['password']);
$re_password = mysqli_real_escape_string($conn, $_POST['re_password']);
// Check if both passwords match
if($password !== $re_password) {
echo '<script>alert("Passwords do not match!");</script>';
} else {
// Proceed with checking the email and phone number in the database
$sql = "SELECT * FROM `users_table` WHERE email='$email' AND phone='$phoneNumber'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// Fetch the first row (assuming email and phone are unique together)
$row = mysqli_fetch_assoc($result);
// Hash the password for security
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
// Update the password in the database
$sql_update = "UPDATE `users_table` SET `password`='$hashed_password' WHERE email='$email' AND phone='$phoneNumber'";
$update_result = mysqli_query($conn, $sql_update);
if($update_result) {
// Redirect to the sign-in page after successful password reset
echo '<script>alert("Password successfully updated!");</script>';
header("location: login.php");
} else {
// Display error message if the update fails
echo '<script>alert("Error updating password. Please try again.");</script>';
}
} else {
// If no matching record found for email and phone
echo '<script>alert("No such user found with the provided email and phone number!");</script>';
}
}
}
?>
<!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://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<title>Reset Password Page</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap');
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Montserrat', sans-serif;
}
body{
background-color: #c9d6ff;
background: linear-gradient(to right, #e2e2e2, #c9d6ff);
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
height: 100vh;
}
.container{
background-color: #fff;
border-radius: 30px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.35);
position: relative;
overflow: hidden;
width: 768px;
max-width: 100%;
min-height: 480px;
}
.container p{
font-size: 14px;
line-height: 20px;
letter-spacing: 0.3px;
margin: 20px 0;
}
.container span{
font-size: 12px;
}
.container a{
color: #333;
font-size: 13px;
text-decoration: none;
margin: 15px 0 10px;
}
.container button{
background-color:green;
color: #fff;
font-size: 12px;
padding: 10px 45px;
border: 1px solid transparent;
border-radius: 8px;
font-weight: 600;
letter-spacing: 0.5px;
text-transform: uppercase;
margin-top: 10px;
cursor: pointer;
}
.container button.hidden{
background-color: transparent;
border-color: #fff;
}
.container form{
background-color: #fff;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 0 40px;
height: 100%;
}
.container input{
background-color: #eee;
border: none;
margin: 8px 0;
padding: 10px 15px;
font-size: 13px;
border-radius: 8px;
width: 100%;
outline: none;
}
.form-container{
position: absolute;
top: 0;
height: 100%;
transition: all 0.6s ease-in-out;
}
.sign-in{
left: 0;
width: 50%;
z-index: 2;
}
.container.active .sign-in{
transform: translateX(100%);
}
.sign-up{
left: 0;
width: 50%;
opacity: 0;
z-index: 1;
}
.container.active .sign-up{
transform: translateX(100%);
opacity: 1;
z-index: 5;
animation: move 0.6s;
}
@keyframes move{
0%, 49.99%{
opacity: 0;
z-index: 1;
}
50%, 100%{
opacity: 1;
z-index: 5;
}
}
.social-icons{
margin: 20px 0;
}
.social-icons a{
border: 1px solid #ccc;
border-radius: 20%;
display: inline-flex;
justify-content: center;
align-items: center;
margin: 0 3px;
width: 40px;
height: 40px;
}
.toggle-container{
position: absolute;
top: 0;
left: 50%;
width: 50%;
height: 100%;
overflow: hidden;
transition: all 0.6s ease-in-out;
border-radius: 150px 0 0 100px;
z-index: 1000;
}
.container.active .toggle-container{
transform: translateX(-100%);
border-radius: 0 150px 100px 0;
}
.toggle{
background-color: #b7a41b;
height: 100%;
background: linear-gradient(to right, green, skyblue);
color: #fff;
position: relative;
left: -100%;
height: 100%;
width: 200%;
transform: translateX(0);
transition: all 0.6s ease-in-out;
}
.container.active .toggle{
transform: translateX(50%);
}
.toggle-panel{
background: linear-gradient(to right, green,green, darkcyan, darkcyan);
position: absolute;
width: 50%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 0 20px;
text-align: center;
top: 0;
transform: translateX(0);
transition: all 0.6s ease-in-out;
}
.toggle-panel img{
margin-top:-2.5rem;
}
.toggle-left{
transform: translateX(-200%);
}
.container.active .toggle-left{
transform: translateX(0);
}
.toggle-right{
right: 0;
transform: translateX(0);
}
.container.active .toggle-right{
transform: translateX(200%);
}
</style>
</head>
<body>
<div class="container" id="container">
<div class="form-container sign-in">
<form method="POST" action="">
<h2 class="text-success">Reset Password</h2><br>
<input type="text" name="username" placeholder="Username" required>
<input type="number" name="phone" placeholder="Telephone Number" required>
<input type="password" name="password" placeholder="New Password" required>
<input type="password" name="repassword" placeholder="Re-enter Password" required><br>
<button type="submit" name="signup">Reset</button>
</form>
</div>
<div class="toggle-container">
<div class="toggle">
<div class="toggle-panel toggle-right">
<img src="images/tree.png" alt="">
<h3>Reset Your Password</h3>
<button class="hidden"><a class="text-light" href="index.php">Go Back</a></button>
</div>
</div>
</div>
</div>
</body>
</html>