-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforgetPassword2.php
More file actions
38 lines (34 loc) · 1.25 KB
/
forgetPassword2.php
File metadata and controls
38 lines (34 loc) · 1.25 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
<?php
if (isset($_POST['pwdAnswer']) && isset($_POST['eMail'])) {
// echo "hello there";
include("mysql_conn.php");
$qry = "SELECT * FROM Shopper WHERE Email=?";
$stmt = $conn->prepare($qry);
$stmt->bind_param("s", $_POST['eMail']);
$stmt->execute();
$result = $stmt->get_result();
$stmt->close();
$row = $result->fetch_array();
$shopperId = $row["ShopperID"];
$email = $row["Email"];
$pwdQuestion = $row["PwdQuestion"];
$pwdAnswer = $row["PwdAnswer"];
if ($_POST['pwdAnswer'] == $pwdAnswer){
$new_pwd = "password";
$hashed_pwd = password_hash($new_pwd, PASSWORD_DEFAULT);
//include("mysql_conn.php");
$qry = "UPDATE Shopper SET Password=? WHERE ShopperID=?";
$stmt = $conn->prepare($qry);
$stmt->bind_param("si", $hashed_pwd, $shopperId);
$stmt->execute();
$stmt->close();
$MainContent = "";
$MainContent = "<h3 style='text-align:center; color:green;'>Your new password is '<b>$new_pwd</b>'. Please change your password once you have logged in.</h3>";
}
else{
$MainContent = "<h3 style='text-align:center; color:red;'>You have entered the wrong answer.</h3>";
}
$conn->close();
}
include("MasterTemplate.php");
?>