-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify_otp.php
52 lines (35 loc) · 1.27 KB
/
verify_otp.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
<?php
session_start();
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "signup";
date_default_timezone_set('Asia/Kolkata');
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$otp = $_POST['otp'];
if (isset($_SESSION['otp']) && $otp == $_SESSION['otp']) {
$email = $_SESSION['email'];
$sql_select = "SELECT id, name FROM registration WHERE email = '$email'";
$result = $conn->query($sql_select);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$id = $row["id"];
$name = $row["name"];
$current_datetime = date('Y-m-d H:i:s');
$sql_insert = "INSERT INTO attendance (id, name, email, attendance, time) VALUES ('$id', '$name', '$email', 'present', '$current_datetime')";
if ($conn->query($sql_insert) === TRUE) {
echo 'Attendance marked successfully. Redirecting...';
} else {
echo 'Error marking attendance: ' . $conn->error;
}
} else {
echo "User details not found.";
}
} else {
echo 'Invalid OTP.';
}
mysqli_close($conn);
?>