-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathvip-booking.php
More file actions
267 lines (229 loc) · 9.38 KB
/
Copy pathvip-booking.php
File metadata and controls
267 lines (229 loc) · 9.38 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<?php
session_start();
require_once "includes/header.php";
require_once "includes/connection.php";
// Check if the user is logged in
if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true) {
// Retrieve the email from the session
$userEmail = $_SESSION['username'];
// Fetch the user's name from the database
$query = "SELECT * FROM registered_users WHERE email='$userEmail'";
$result = mysqli_query($conn, $query);
if ($result) {
if (mysqli_num_rows($result) == 1) {
$userData = mysqli_fetch_assoc($result);
$userName = $userData['name'];
// Continue with the rest of your booking script
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieve and process form data
$name = $userName; // Use the fetched name
$email = $userEmail;
// Check if 'section' is set in $_POST
if (isset($_POST['section'])) {
$sectionArray = $_POST['section'];
// Initialize arrays to store sections, seats, and decor
$sections = [];
$seats = [];
$decor = [];
// Iterate through sections and seats
foreach ($sectionArray as $sectionName => $seatsArray) {
// Check if the seat is set, otherwise set a default value
$selectedSeat = (isset($seatsArray[0])) ? $seatsArray[0] : 'NONE';
// Concatenate seats for each section
$seats[] = $selectedSeat;
$sections[] = $sectionName;
// Check if decor is set, otherwise set a default value
$selectedDecor = (isset($seatsArray[1])) ? $seatsArray[1] : 'NONE';
// Concatenate decor for each section
$decor[] = $selectedDecor;
}
// Concatenate sections, seats, and decor as comma-separated strings
$sectionsString = implode(",", $sections);
$seatsString = implode(",", $seats);
$decorString = implode(",", $decor);
// Retrieve other form data
$date = $_POST['date'];
$time = $_POST['time'];
$time = strtolower($time);
$payment = 0;
// Insert data into the VIP table
$table = 'table_booking_vip';
$sql = "INSERT INTO $table (name, email, section, seat, decor, date, time, payment)
VALUES ('$name', '$email', '$sectionsString', '$seatsString', '$decorString', '$date', '$time', $payment)";
if ($conn->query($sql) === TRUE) {
// Redirect to a success page or handle success
echo "<script>alert('VIP Table Booked Successfully');
window.location.href = 'vip-payment-verification.php';
</script>";
exit();
} else {
// Handle errors
echo "<script>alert('ERROR in VIP table Booking');</script>";
}
} else {
// Handle the case where 'section' is not set in $_POST
echo "<script>alert('No section data received');</script>";
}
}
} else {
// Handle the case where the email is not found in the database
echo "<script>alert('Email not registered');</script>";
echo "<script>window.location.href='login.php';</script>";
exit();
}
} else {
// Handle database query error
echo "<script>alert('ERROR in processing your request');</script>";
exit();
}
} else {
// Handle the case where the user is not logged in
echo "<script>alert('Log in to access VIP booking');</script>";
echo "<script>window.location.href='new-login.php';</script>";
exit();
}
$conn->close();
?>
<style>
.clear {
clear: both;
}
.content {
margin-left: 20px;
}
.checkBox {
display: inline-block;
cursor: pointer;
width: 30px;
height: 30px;
border: 3px solid rgba(255, 255, 255, 0);
border-radius: 10px;
position: relative;
overflow: hidden;
box-shadow: 0px 0px 0px 2px black;
color: black; /* Set default text color */
}
.checkBox div {
width: 60px;
height: 60px;
background-color: rgba(0, 0, 0, 0.5); /* 50% opacity black */
top: -52px;
left: -52px;
position: absolute;
transform: rotateZ(45deg);
z-index: 100;
}
.checkBox input[type=checkbox]:checked + div {
left: -10px;
top: -10px;
}
.checkBox input[type=checkbox] {
position: absolute;
left: 50px;
visibility: hidden;
}
.transition {
transition: 300ms ease;
}
.checkBox input[type=checkbox]:checked + div + span {
color: white; /* Set text color to white when checked */
}
.box {
border: 5px solid #ccc; /* Border color and thickness */
padding: 10px; /* Padding inside the box */
border-radius: 10px; /* Rounded corners */
background-color: #f9f9f9; /* Background color */
max-width: 600px; /* Adjust the maximum width as per your preference */
margin: auto; /* Center the box */
color: grey;
}
.button {
background-image: linear-gradient(to right, #0d5215, green);
color: white;
max-width: 600px;
font-size: var(--fs-7);
text-transform: uppercase;
padding: 20px 30px;
text-align: center;
border-radius: 7px;
}
.hero-banner img {
max-width: 100%; /* Make images responsive */
height: auto; /* Maintain aspect ratio */
display: block; /* Remove extra space under the image */
margin: auto; /* Center the image */
margin-top: 13px; /* Add margin-top to move the image downward */
}
@media screen and (max-width: 1000px) {
.hero-banner img {
max-width: 100%;
margin-top: 10px;
}
}
</style>
<center><button class="button" style="width:100%; padding-top:8em"><a href="table-booking.php" style="color:white"> Go To Normal Booking Section</a></button></center>
<section class="contact-section" id="home">
<section class="contact-section" id="home">
<div class="contact-container">
<div class="contact-content">
<section>
<form action="" method="post">
<center><h2 style="color:#0d5215">First Floor [VIP]</h2></center><br>
<!-- Family Section -->
<div class="box">
<div class="content">
<center><h3>VIP section</h3></center>
<hr>
<!-- Use dropdowns for seat selection -->
<div class="form-field">
<label for="family_seat">Select Seat:</label>
<select id="family_seat" name='section[VIP][]'>
<option value="NONE">None</option>
<option value="v1">V1</option>
<option value="v2">V2</option>
<option value="v3">V3</option>
<option value="v4">V4</option>
<option value="v5">V5</option>
<option value="v6">V6</option>
</select>
</div>
<!-- Use dropdowns for customize selection -->
<div class="form-field">
<label for="family_seat">Select decor:</label>
<select id="family_seat" name='section[VIP][]'>
<option value="NONE">None</option>
<option value="Candle light">Candle light</option>
<option value="Special live rose flower pot">Special live rose flower pot</option>
<option value="Chandeliers">Chandeliers</option>
</select>
</div>
</div>
</div>
<br>
<!-- Add date and time input fields with JavaScript to populate them automatically -->
<div class="box">
<div class="form-field">
<label for="date">Date:</label>
<input type="date" id="date" name="date" required>
</div>
<div class="form-field">
<label for="time">Time:</label>
<input type="text" id="time" name="time" placeholder="eg: 01:30 pm" pattern="^(0[1-9]|1[0-2]):[0-5][0-9] [apAP][mM]$" title="Enter a valid time (hh:mm am/pm)" required>
</div>
</div>
<br>
<button>
<br><hr><br>
</section>
</div>
<figure class="hero-banner">
<center><h2 style="color:#0d5215">First Floor [VIP]</h2></center><br>
<img width='600' src="assets/images/table-book/first-floor.png" alt='Blue print image [load error]'>
<br>
<center><input type="submit" class="button" value="Book VIP Tables" style="float:left"></center>
<center><button class="button"><a href="vip-payment-verification.php" style="color:white">Your VIP Bookings</a></button></center>
</form>
</figure>
</div>
</section>
<?php require "includes/footer.php"; ?>