-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreset-password.php
More file actions
146 lines (110 loc) · 5.56 KB
/
Copy pathreset-password.php
File metadata and controls
146 lines (110 loc) · 5.56 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Password Recovery | Bookly </title>
<link rel="icon" href="./assets/images/illustrations/logo.png">
<!--google Fonts-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./assets/css/root.css" />
<!-- edit profile css -->
<link rel="stylesheet" href="./assets/css/getstarted.css">
<link rel="stylesheet" href="./assets/css/toast.css">
<link rel="stylesheet" type="text/css" href="./assets/css/forgot_password.css" />
</head>
<body>
<div id="toast" style="align-self:center"></div>
<div class="pw_container">
<div class="pw_content">
<?php
include('assets/php/db-config.php');
$error="";
if (isset($_GET["key"]) && isset($_GET["email"]) && isset($_GET["action"]) && ($_GET["action"] == "reset") && !isset($_POST["action"])) {
$key = $_GET["key"];
$email = $_GET["email"];
$curDate = date("Y-m-d H:i:s");
$query = mysqli_query($conn, "SELECT * FROM `password_reset_temp` WHERE `rkey`='" . $key . "' and `email`='" . $email . "';");
$row = mysqli_num_rows($query);
if ($row == "") {
$error .= '<h2>Invalid Link</h2>';
} else {
$row = mysqli_fetch_assoc($query);
$expDate = empty($row['expDate']) ? "" : $row['expDate'];
if ($expDate >= $curDate) {
?>
<h2 class="title-fpw">Recovery Password</h2>
<form class="fpw-form-container" method="post" action="" name="update">
<input type="hidden" name="action" value="update" class="form-control" />
<div class="content-wrapper block-1233">
<label id="new_password" class="pass-label" for="contact">New Password</label>
<input class="txt-field" id="new_password" name="pass1" type="password"
placeholder="Enter your new password" required />
<span class=" error-inp-field error-pass">
<?php //echo $new_passwordErr; ?>
</span>
<!-- <i class="fa fa-eye" aria-hidden="true"></i> -->
</div>
<div class="content-wrapper block-1233">
<label id="new_password_confirm" class="pass-label" for="contact">Confirm New Password</label>
<input class="txt-field" id="new_password_confirm" name="pass2" type="password"
placeholder="Confirm your new password" required />
<span class="error-inp-field error-pass">
<?php //echo $new_password_confirmErr; ?>
</span>
<input type="hidden" name="email" value="<?php echo $email; ?>" />
<!-- <i class="fa fa-eye" aria-hidden="true"></i> -->
</div>
<div class="save-btn-container">
<input type="submit" class="save-pw-btn" id="reset-password" name="reset-password"
value="Reset Password " />
</div>
</form>
<?php
} else {
$error .= "<h2>Link Expired</h2>";
}
}
if ($error != "") {
echo "<div class='error'>" . $error . "</div><br />";
}
}
if (isset($_POST["email"]) && isset($_POST["action"]) && ($_POST["action"] == "update")) {
$error = "";
$pass1 = mysqli_real_escape_string($conn, $_POST["pass1"]);
$pass2 = mysqli_real_escape_string($conn, $_POST["pass2"]);
$email = $_POST["email"];
$curDate = date("Y-m-d H:i:s");
if ($pass1 != $pass2) {
$error .= "<p>Password do not match, both password should be same.<br /><br /></p>";
}
if ($error != "") {
echo $error;
} else {
mysqli_query($conn, "UPDATE `account_user` SET `password` = '$pass1' WHERE `email` = '$email'");
mysqli_query($conn, "DELETE FROM `password_reset_temp` WHERE `email` = '$email'");
// echo '<div class="success-reset-password">
// <p>Your password has been reset successfully.</p>
// <p>You can now <a href="../">login</a> with your new password.</p>
// </div>';
echo "<script>window.location.href='home?signin=sign-in-321jkh1jkasd';</script>";
}
}
?>
</div>
</div>
<script>
function showResetPasswordToast() {
toast({
message: ">Congratulations! Your password has been updated successfully.",
type: "success",
duration: 5000
});
}
</script>
<script src="./assets/javascript/toast.js"></script>
</body>
</html>