forked from tasminoni/CSE370-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbookingstatus.php
136 lines (103 loc) · 4.57 KB
/
bookingstatus.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
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
126
127
128
129
130
131
132
133
134
135
136
<?php
session_start();
$servername = "localhost";
$username = "root";
$password = "";
$database = "db";
$mysqli = new mysqli($servername, $username, $password, $database);
if ($mysqli->connect_errno) {
echo "Error connecting to the database. Please try again later.";
exit;
}
$emailQuery = "SELECT email FROM userinfo ORDER BY id DESC LIMIT 1";
$result = $mysqli->query($emailQuery);
if ($result && $result->num_rows > 0) {
$row = $result->fetch_assoc();
$latestEmail = $row['email'];
$userDataQuery = "SELECT * FROM user WHERE email = '$latestEmail'";
$userDataResult = $mysqli->query($userDataQuery);
if ($userDataResult && $userDataResult->num_rows > 0) {
$user = $userDataResult->fetch_assoc();
$name = $user['name'];
$email=$user['email'];
$bookingQuery = "SELECT * FROM booking WHERE name = '$name' AND email = '$email'";
$bookingResult = $mysqli->query($bookingQuery);
$userDataResult->close();
if ($bookingResult && $bookingResult->num_rows > 0) {
while ($booking = $bookingResult->fetch_assoc()) {
echo "<div class='booking-box'>";
echo "<p><strong>Name:</strong> " . htmlspecialchars($user['name']) . "</p>";
echo "<p><strong>Email:</strong> " . htmlspecialchars($user['email']) . "</p>";
echo "<p><strong>Phone:</strong> " . htmlspecialchars($booking['phone']) . "</p>";
echo "<p><strong>Flat ID:</strong> " . htmlspecialchars($booking['Flatid']) . "</p>";
echo "<p><strong>Check-in Date:</strong> " . htmlspecialchars($booking['checkin_date']) . "</p>";
echo "<p><strong>Check-out Date:</strong> " . htmlspecialchars($booking['checkout_date']) . "</p>";
echo "<p><strong>Amount:</strong> " . htmlspecialchars($booking['amount']) . "</p>";
echo "<p><strong>Mafia Amount:</strong> " . htmlspecialchars($booking['mafia_amount']) . "</p>";
echo "<p><strong>Total Amount:</strong> " . htmlspecialchars($booking['total_amount']) . "</p>";
echo "<p><strong>Payment Status:</strong> " . htmlspecialchars($booking['pay_status']) . "</p>";
echo "</div>";
}
} else {
echo "<p>No bookings found for this user.</p>";
}
} else {
echo "User data not found for the latest email.";
}
} else {
echo "No email found in the userinfo table.";
}
$mysqli->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User Booking Information</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
}
.booking-info {
border: 1px solid #ccc;
border-radius: 5px;
padding: 20px;
margin-bottom: 20px;
}
.booking-info h2 {
margin-top: 0;
}
.booking-box {
border: 1px solid #ccc;
border-radius: 5px;
padding: 20px;
margin-bottom: 20px;
}
</style>
</head>
<body>
<?php
if ($bookingResult && $bookingResult->num_rows > 0) {
while ($booking = $bookingResult->fetch_assoc()) {
echo "<div class='booking-box'>";
echo "<p><strong>Name:</strong> " . htmlspecialchars($user['name']) . "</p>";
echo "<p><strong>Email:</strong> " . htmlspecialchars($user['email']) . "</p>";
echo "<p><strong>Phone:</strong> " . htmlspecialchars($booking['phone']) . "</p>";
echo "<p><strong>Flat ID:</strong> " . htmlspecialchars($booking['Flatid']) . "</p>";
echo "<p><strong>Check-in Date:</strong> " . htmlspecialchars($booking['checkin_date']) . "</p>";
echo "<p><strong>Check-out Date:</strong> " . htmlspecialchars($booking['checkout_date']) . "</p>";
echo "<p><strong>Amount:</strong> " . htmlspecialchars($booking['amount']) . "</p>";
echo "<p><strong>Mafia Amount:</strong> " . htmlspecialchars($booking['mafia_amount']) . "</p>";
echo "<p><strong>Total Amount:</strong> " . htmlspecialchars($booking['total_amount']) . "</p>";
echo "<p><strong>Payment Status:</strong> " . htmlspecialchars($booking['pay_status']) . "</p>";
echo "</div>";
}
} else {
echo "<p>No bookings found for this user.</p>";
}
?>
</body>
</html>