forked from LahiruSen/OOSD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset.php
70 lines (57 loc) · 2.06 KB
/
reset.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
<?php
/* The password reset form, the link to this page is included
from the forgot.php email message
*/
require 'db.php';
if (session_status() == PHP_SESSION_NONE) { session_start();}
// Make sure email and hash variables aren't empty
if( isset($_GET['email']) && !empty($_GET['email']) AND isset($_GET['hash']) && !empty($_GET['hash']) )
{
$email = $mysqli->escape_string($_GET['email']);
$hash = $mysqli->escape_string($_GET['hash']);
// Make sure user email with matching hash exist
$result = $mysqli->query("SELECT * FROM users WHERE email='$email' AND hash='$hash'");
if ( $result->num_rows == 0 )
{
$_SESSION['message'] = "You have entered invalid URL for password reset!";
header("location: error.php");
}
}
else {
$_SESSION['message'] = "Sorry, verification failed, try again!";
header("location: error.php");
}
?>
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Reset Your Password</title>
<?php include 'css/css.html'; ?>
</head>
<body>
<div class="form">
<h1>Choose Your New Password</h1>
<form action="reset_password.php" method="post">
<div class="field-wrap">
<label>
New Password<span class="req">*</span>
</label>
<input type="password"required name="newpassword" autocomplete="off"/>
</div>
<div class="field-wrap">
<label>
Confirm New Password<span class="req">*</span>
</label>
<input type="password"required name="confirmpassword" autocomplete="off"/>
</div>
<!-- This input field is needed, to get the email of the user -->
<input type="hidden" name="email" value="<?= $email ?>">
<input type="hidden" name="hash" value="<?= $hash ?>">
<button class="button button-block"/>Apply</button>
</form>
</div>
<script src='js/jquery.min.js'></script>
<script src="js/index.js"></script>
</body>
</html>