-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitreset.php
82 lines (69 loc) · 2.52 KB
/
initreset.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
81
82
<?php
include '../config/conn.php';
// check Login request
if (!empty($_POST['btnReset'])) {
$email = trim($_POST['email']);
if ($email == "") {
$login_error_message = 'Email is required!';
echo $login_error_message . "<br>";
} else {
try {
// prepare sql and bind parameters
$stmt3 = $conn->prepare("SELECT confirmation_code FROM users WHERE email=:email");
$stmt3->bindParam(':email', $email);
$stmt3->execute();
if ($stmt3->rowCount() > 0) {
$row = $stmt3->fetch();
$confirm_code = $row['confirmation_code'];
// ---------------- SEND MAIL FORM ----------------
// send e-mail to ...
$to=$email;
// Your subject
$subject="Your Matcha password link is here";
// From
$header="from: Matcha";
// Your message
$message="Your password reset link \r\n";
$message.="Click on this link to reset your password \r\n";
$message.="http://localhost:8080/matcha/inc/resetlink.php?passkey=$confirm_code";
// send email
$sentmail = mail($to,$subject,$message,$header);
// if your email succesfully sent
if($sentmail){
echo "Your Reset Password Link Has Been Sent To Your Email Address.";
} else {
echo "Cannot send Reset Password Link to your e-mail address";
}
} else {
echo "Incorrect Email!" . "<br>";
}
} catch (PDOException $e) {
echo "error: " . $e->getMessage();
}
$conn = null;
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Matcha - Reset</title>
</head>
<body>
<div class="container">
<div class="row">
<h4>Reset Password</h4>
<form action="initreset.php" method="post">
<div class="form-group">
<label for="">Email</label>
<input type="email" name="email" class="form-control"/>
</div>
<div class="form-group">
<input type="submit" name="btnReset" class="btn btn-primary" value="Reset"/>
</div>
</form>
</div>
</div>
</body>
</html>