Repository navigation
Expand file tree
/
Copy pathverify.php
More file actions
executable file
·125 lines (116 loc) · 5.28 KB
/
Copy pathverify.php
File metadata and controls
executable file
·125 lines (116 loc) · 5.28 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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
session_start();
include('config.php');
include('sessioncheck.php');
$uid = $_SESSION['log']['useruid'];
$error_message = '';
$success_message = '';
// --- OTP PROCESSING LOGIC ---
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$car = $_POST['car'];
$date = $_POST['datetimelocal'];
if (isset($_POST['otp_type']) && $_POST['otp_type'] == 'otp1') {
// Logic from otp1.php
$otp1 = $_POST['otp1'];
$qry = mysqli_query($conn, "SELECT * FROM logtable WHERE otp1='$otp1' AND useruid='$uid'");
if (mysqli_num_rows($qry) > 0) {
$row = mysqli_fetch_array($qry);
if ($row['carno'] == $car) {
mysqli_query($conn, "UPDATE logtable SET fromtime='$date', status='Park' WHERE otp1='$otp1'");
mysqli_query($conn, "UPDATE lot SET status='Booked' WHERE lotname='{$row['lotname']}'");
$success_message = "Verification successful! You may now park your car.";
} else {
$error_message = "Invalid Car Number for this booking.";
}
} else {
$error_message = "Invalid OTP entered.";
}
}
elseif (isset($_POST['otp_type']) && $_POST['otp_type'] == 'otp2') {
// Logic from otp2.php
$otp2 = $_POST['otp2'];
$qry = mysqli_query($conn, "SELECT * FROM logtable WHERE otp2='$otp2' AND useruid='$uid'");
if (mysqli_num_rows($qry) > 0) {
$row = mysqli_fetch_array($qry);
if ($row['carno'] == $car) {
mysqli_query($conn, "UPDATE logtable SET totime='$date', status='Left' WHERE otp2='$otp2'");
mysqli_query($conn, "UPDATE lot SET status='Leaving' WHERE lotname='{$row['lotname']}'");
// Redirect to payment page
header("Location: fee.php");
exit();
} else {
$error_message = "Invalid Car Number for this booking.";
}
} else {
$error_message = "Invalid OTP entered.";
}
}
}
include('header.php');
// --- FORM DISPLAY LOGIC ---
$qry_status = mysqli_query($conn, "SELECT * FROM logtable WHERE useruid='$uid' ORDER BY id DESC LIMIT 1");
$booking_data = mysqli_fetch_array($qry_status);
?>
<div class="form-container">
<div class="form-wrapper">
<h1 class="form-title">Parking Verification</h1>
<?php if (!empty($success_message)): ?>
<div class="success-banner"><?php echo $success_message; ?></div>
<?php endif; ?>
<?php if (!empty($error_message)): ?>
<div class="error-banner"><?php echo $error_message; ?></div>
<?php endif; ?>
<?php
// If status is 'Park', show OTP2 form. Otherwise, show OTP1 form.
if ($booking_data && $booking_data['status'] == 'Park') {
?>
<!-- OTP2 Form (Leaving) -->
<p class="form-subtitle">Enter your second OTP to check out and leave the parking lot.</p>
<form method="post" action="verify.php" class="modern-form">
<input type="hidden" name="otp_type" value="otp2">
<div class="form-group">
<label for="otp2">OTP-2 (While Leaving)</label>
<input type="number" id="otp2" name="otp2" placeholder="Enter your second OTP" required>
</div>
<div class="form-group">
<label for="car">Car Number</label>
<input type="text" id="car" name="car" value="<?php echo htmlspecialchars($booking_data['carno']); ?>" required>
</div>
<input type="hidden" name="datetimelocal" value="<?php echo date("Y-m-d\TH:i:s"); ?>">
<div class="form-group">
<button type="submit" class="button button-primary form-button">Verify & Proceed to Pay</button>
</div>
</form>
<?php
} else if ($booking_data && $booking_data['status'] != 'Left' && $booking_data['payment'] != 'Paid') {
?>
<!-- OTP1 Form (Parking) -->
<p class="form-subtitle">Enter your first OTP to confirm your arrival and park your car.</p>
<form method="post" action="verify.php" class="modern-form">
<input type="hidden" name="otp_type" value="otp1">
<div class="form-group">
<label for="otp1">OTP-1 (While Parking)</label>
<input type="number" id="otp1" name="otp1" placeholder="Enter your first OTP" required>
</div>
<div class="form-group">
<label for="car">Car Number</label>
<input type="text" id="car" name="car" value="<?php echo htmlspecialchars($booking_data['carno']); ?>" required>
</div>
<input type="hidden" name="datetimelocal" value="<?php echo date("Y-m-d\TH:i:s"); ?>">
<div class="form-group">
<button type="submit" class="button button-primary form-button">Verify & Park</button>
</div>
</form>
<?php
} else {
?>
<p class="form-subtitle">You have no active bookings to verify.</p>
<a href="book.php" class="button">Book a Slot</a>
<?php
}
?>
</div>
</div>
<?php
include('footer.php');
?>