-
Notifications
You must be signed in to change notification settings - Fork 5
/
reset-password.php
57 lines (38 loc) · 1.17 KB
/
reset-password.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
<?php
$token = $_GET["token"];
$token_hash = hash("sha256", $token);
$mysqli = require __DIR__ . "/database.php";
$sql = "SELECT * FROM user
WHERE reset_token_hash = ?";
$stmt = $mysqli->prepare($sql);
$stmt->bind_param("s", $token_hash);
$stmt->execute();
$result = $stmt->get_result();
$user = $result->fetch_assoc();
if ($user === null) {
die("token not found");
}
if (strtotime($user["reset_token_expires_at"]) <= time()) {
die("token has expired");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Reset Password</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
</head>
<body>
<h1>Reset Password</h1>
<form method="post" action="process-reset-password.php">
<input type="hidden" name="token" value="<?= htmlspecialchars($token) ?>">
<label for="password">New password</label>
<input type="password" id="password" name="password">
<label for="password_confirmation">Repeat password</label>
<input type="password" id="password_confirmation"
name="password_confirmation">
<button>Send</button>
</form>
</body>
</html>