-
Notifications
You must be signed in to change notification settings - Fork 1
/
auserbooksearch.php
269 lines (188 loc) · 5.85 KB
/
auserbooksearch.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
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
268
269
<?php
session_start();
// Step 1: Establish a database connection
$servername = "localhost:3307";
$username = "root";
$password = "";
$dbname = "testdb";
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Step 2: Retrieve all tours available
// $tours_query = "SELECT id, place, price, description FROM tours";
// $tours_result = mysqli_query($conn, $tours_query);
$tours_query = "SELECT tours.*, tourdate.date FROM tours INNER JOIN tourdate ON tours.Id = tourdate.tour_id WHERE tours.place = '".$_POST['place']."' AND tourdate.date = '".$_POST['tour_date']."'";
$tours_result = mysqli_query($conn, $tours_query);
// Step 5: Check user authentication
// if ($_SESSION['usertype'] != 'user') {
// echo "Only users can book tours";
// exit();
// }
// $_SESSION['user_id']=1;
// Step 6: Handle booking form submission
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$user_id = $_SESSION['user_id'];
$tour_id = $_POST['tour_id'];
$_SESSION['tour_id'] = $tour_id;
$booking_date = "CURRENT_DATE()";
$booking_query = "INSERT INTO bookings (user_id, tour_id,booking_date) VALUES ($user_id, $tour_id,$booking_date)";
mysqli_query($conn, $booking_query);
echo "Booking successful!";+
header("Location: paymentpage.php");
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SkyFly - Explore the World</title>
<!--
- favicon
-->
<link rel="shortcut icon" href="./favicon.svg" type="image/svg+xml">
<!--
- custom css link
-->
<link rel="stylesheet" href="./assets/css/style.css">
<!--
- google font link
-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Abril+Fatface&family=Comforter+Brush&family=Heebo:wght@400;500;600;700&display=swap"
rel="stylesheet">
</head>
<style>
th,td{
padding: 10px;
border: 2px solid black;
border-color: #00cccc;
}
</style>
<body id="top">
<!--
- #HEADER
-->
<header class="header" data-header>
<div class="container">
<a href="#">
<h1 class="logo">SkyFly</h1>
</a>
<button class="nav-toggle-btn" data-nav-toggle-btn aria-label="Toggle Menu">
<ion-icon name="menu-outline" class="open"></ion-icon>
<ion-icon name="close-outline" class="close"></ion-icon>
</button>
<nav class="navbar">
<ul class="navbar-list">
<li>
<a href="#" class="navbar-link">Destinations</a>
</li>
<li>
<a href="/tours.html" class="navbar-link">Tours</a>
</li>
<li>
<a href="/hotels.html" class="navbar-link">Hotels</a>
</li>
<li>
<a href="/aboutus.html" class="navbar-link">About Us</a>
</li>
<li>
<a href="userfinalviewtable.php" class="navbar-link">My booked tours</a>
</li>
</ul>
<a href="#" class="btn btn-secondary">Booking Now</a>
</nav>
</div>
</header>
<main>
<article>
<section class="section blog">
<div class="container">
<h1>Welcome, <?php echo $_SESSION['username']; ?>!</h1>
<h1>your id is , <?php echo $_SESSION['user_id']; ?>!</h1>
<h2>Tours Available:</h2>
<table>
<thead>
<tr>
<th>ID</th>
<th>Place</th>
<th>Price</th>
<th>Description</th>
<th>Book</th>
</tr>
</thead>
<tbody>
<?php while ($tour = mysqli_fetch_assoc($tours_result)): ?>
<tr>
<td><?php echo $tour['id']; ?></td>
<td><?php echo $tour['place']; ?></td>
<td><?php echo $tour['price']; ?></td>
<td><?php echo $tour['description']; ?></td>
<td><?php echo $tour['date']; ?></td>
<td>
<form method="POST">
<input type="hidden" name="tour_id" value="<?php echo $tour['id']; ?>">
<button type="submit" class="btn btn-primary">Book</button>
</form>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</article>
</main>
<!--
- #FOOTER
-->
<footer class="footer" style="background-image: url('./assets/images/footer-bg.png')">
<div class="container">
<div class="footer-top">
</div>
<div class="footer-bottom">
<a href="#" class="logo">SkyFly</a>
<p class="copyright">
© 2022 <a href="#" class="copyright-link">SkyFLy</a>. All Rights Reserved
</p>
<ul class="social-list">
<li>
<a href="#" class="social-link">
<ion-icon name="logo-facebook"></ion-icon>
</a>
</li>
<li>
<a href="#" class="social-link">
<ion-icon name="logo-twitter"></ion-icon>
</a>
</li>
<li>
<a href="#" class="social-link">
<ion-icon name="logo-instagram"></ion-icon>
</a>
</li>
<li>
<a href="#" class="social-link">
<ion-icon name="logo-linkedin"></ion-icon>
</a>
</li>
<li>
<a href="#" class="social-link">
<ion-icon name="logo-google"></ion-icon>
</a>
</li>
</ul>
</div>
</div>
</footer>
<!--
- #GO TO TOP
-->
<a href="#top" class="go-top" data-go-top aria-label="Go To Top">
<ion-icon name="chevron-up-outline"></ion-icon>
</a>
<script src="./assets/js/script.js"></script>
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>
</body>
</html>