-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforget_password_otp_action.php
36 lines (30 loc) · 1.07 KB
/
forget_password_otp_action.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
<?php
session_start(); // Start the session
include_once('connection.php');
if (isset($_POST['btn'])) {
// Get the OTP entered by the user
$enteredOTP = $_POST['otp'];
// Query to fetch the email and token based on the entered OTP
$query = "SELECT Email, Token FROM token WHERE OTP = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("i", $enteredOTP); // Assuming OTP is an integer
$stmt->execute();
$stmt->store_result();
// If a record with the entered OTP exists
if ($stmt->num_rows == 1) {
$stmt->bind_result($email, $token);
$stmt->fetch();
// Set retrieved email and token in session
$_SESSION['forget_em'] = $email;
$_SESSION['forget_token'] = $token;
// Redirect to new password page
header("Location: new_password.php");
exit();
} else {
// No record found with the entered OTP
$_SESSION['error'] = "Invalid OTP. Please try again.";
header("Location: forget_password_otp.php");
exit();
}
}
?>