This repository has been archived by the owner on Oct 4, 2024. It is now read-only.
forked from gg1711/Visitor-Management-System
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exit.php
86 lines (63 loc) · 2.39 KB
/
exit.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
83
84
85
86
<?php
include("connect.php");
include("function.php");
?>
<?php
// define variables and set to empty values
$UserId = $Name = $Email = $Phone = $HostName = $HostEmail = $HostPhone = $Depart = "ccc";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$UserId = test_input($_POST["UserId"]);
$Email = test_input($_POST["Email"]);
}
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<?php
date_default_timezone_set('Asia/Kolkata');
$Arrive = "";
if ($Email != $Phone) {
$sql1 = "SELECT * FROM visitors WHERE UserId = '$UserId' and Email = '$Email' ";
$sql1 = mysqli_query($conn, $sql1) or die(mysqli_error($conn));
if ($sql1->num_rows == 0) {
$message = "Your Email and UserID not matched. Check your Email for UserId";
echo "<script type='text/javascript'>;alert('$message');window.location.href='index.html';</script>";
}
$row = $sql1->fetch_assoc();
$Username = $row["Username"];
$Arrive = $row["Arrival"];
$Depart = $row["Departure"];
$Phone = $row["Phone"];
$Address = $row["Address"];
$HostName = $row["HostName"];
if ($Depart != "Inside") {
$message = "You have already checked out";
echo "<script type='text/javascript'>;alert('$message');window.location.href='index.html';</script>";
}
$Depart = date('Y/m/d H:i:s');
// echo $sql1->num_rows ."<br>";
//echo $Username.$Arrive.$Depart.$Phone;
$sql3 = "UPDATE visitors SET Departure='$Depart' WHERE UserId='$UserId' ";
// echo $sql3." cvcxv ".$Depart;
if (mysqli_query($conn, $sql3) == TRUE) {
$message = "Thank You for visiting Us. You will receive a mail soon. Check your Inbox (Spam too).";
//echo $message, "Your UserID is ", $UserId;
send_email_depart($Username, $UserId, $Email, $Phone, $Arrive, $Depart, $HostName, $Address);
echo "<script type='text/javascript'>;alert('$message');
window.location.href='index.html';
</script>";
} else {
/*printf("error: %s\n", mysqli_error($conn)); //very important to check error
*/
$message = "Oops, the server seems to be too busy. Our bad. Please try again.";
echo "<script type='text/javascript'>;alert('$message');window.location.href='index.html';</script>";
}
} else {
$message = "Please Enter Email and Phone No. correctly";
echo "<script type='text/javascript'>;alert('$message');window.location.href='index.php';</script>";
}
?>