-
Notifications
You must be signed in to change notification settings - Fork 0
/
forgot.php
80 lines (60 loc) · 2.1 KB
/
forgot.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
71
72
73
74
75
76
77
78
79
80
<?php
/* Reset your password form, sends reset.php password link */
//require 'db.php';
require_once("db.php");
session_start();
// Check if form submitted with method="post"
if ( $_SERVER['REQUEST_METHOD'] == 'POST' )
{
$email = $conn->escape_string($_POST['email']);
$result = $conn->query("SELECT * FROM users WHERE email='$email'");
if ( $result->num_rows == 0 ) // User doesn't exist
{
$_SESSION['message'] = "User with that email doesn't exist!";
header("location: error.php");
}
else { // User exists (num_rows != 0)
$user = $result->fetch_assoc(); // $user becomes array with user data
$email = $user['email'];
$hash = $user['hash'];
$first_name = $user['first_name'];
// Session message to display on success.php
$_SESSION['message'] = "<p>Please check your email <span>$email</span>"
. " for a confirmation link to complete your password reset!</p>";
// Send registration confirmation link (reset.php)
$to = $email;
$subject = 'Password Reset Link ( clevertechie.com )';
$message_body = '
Hello '.$first_name.',
You have requested password reset!
Please click this link to reset your password:
http://localhost/DonorHub_Web/reset.php?email='.$email.'&hash='.$hash;
$from='From: donotreply@donorhub.com';
mail($to, $subject, $message_body, $from);
header("location: success.php");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Reset Your Password</title>
<?php include 'css/css.html'; ?>
</head>
<body>
<div class="form">
<h1>Reset Your Password</h1>
<form action="forgot.php" method="post">
<div class="field-wrap">
<label>
Email Address<span class="req">*</span>
</label>
<input type="email"required autocomplete="off" name="email"/>
</div>
<button class="button button-block"/>Reset</button>
</form>
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/index.js"></script>
</body>
</html>