-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpin_verification.php
More file actions
32 lines (26 loc) · 833 Bytes
/
pin_verification.php
File metadata and controls
32 lines (26 loc) · 833 Bytes
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
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "lost_found_db";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$email = $_POST['email'];
$otp = $_POST['otp'];
// Check if email and OTP match in the database
$sql = "SELECT * FROM users WHERE email = '$email' AND otp = '$otp'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// OTP is valid
// You may want to add a timestamp check here to ensure the OTP hasn't expired
echo json_encode(['status' => 'success', 'message' => 'OTP verified successfully']);
} else {
// OTP is invalid
echo json_encode(['status' => 'error', 'message' => 'Invalid OTP']);
}
$conn->close();
?>