-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforgot-process.php
More file actions
30 lines (25 loc) · 1.01 KB
/
Copy pathforgot-process.php
File metadata and controls
30 lines (25 loc) · 1.01 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
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$email = $_POST['email'] ?? '';
$mobile = $_POST['mobile'] ?? '';
$new_password = $_POST['new_password'] ?? '';
if (empty($email) || empty($mobile) || empty($new_password)) {
echo "<script>alert('All fields are required!'); window.history.back();</script>";
exit();
}
$folder = "users/$mobile";
$file = "$folder/data.json";
if (!file_exists($file)) {
echo "<script>alert('User not found!'); window.history.back();</script>";
exit();
}
$user_data = json_decode(file_get_contents($file), true);
if ($user_data['email'] === $email && $user_data['mobile'] === $mobile) {
$user_data['password'] = $new_password;
file_put_contents($file, json_encode($user_data));
echo "<script>alert('Password updated successfully!'); window.location.href='signup.php';</script>";
} else {
echo "<script>alert('Email or mobile does not match!'); window.history.back();</script>";
}
}
?>