-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnewpaidalltours_confirm.php
156 lines (127 loc) · 4.39 KB
/
newpaidalltours_confirm.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
<!DOCTYPE html>
<html>
<head>
<title>My Bookings</title>
<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>
<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>
</ul>
<a href="./logout.php" class="btn btn-secondary">logout</a>
</nav>
</div>
</header>
<!-- <h2>Welcome <?php echo $_SESSION['username']; ?>!</h2> -->
<div class="container">
<h1>Confirmation page</h1>
<table>
<tr>
<th>Id</th>
<th>place</th>
<th>date</th>
<th>price</th>
<th>number of people</th>
<th>total price</th>
<th>cancel the booking</th>
</tr>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
// Establish a connection to the MySQL server
$host = 'localhost:3307';
$username = 'root';
$password = '';
$dbname = 'testdb';
try {
$conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Prepare and execute the SQL statement to retrieve the user's bookings
// $stmt = $conn->prepare("SELECT tours.place, datetour.date, tours.price FROM bookings JOIN tours ON bookings.tour_id = tours.Id JOIN datetour ON bookings.tour_id = datetour.tour_id WHERE bookings.user_id = :user_id");
// $stmt->bindParam(':user_id', $_SESSION['user_id']);
// $stmt->execute();
// // Fetch the results and display them in the table
// while ($row = $stmt->fetch()) {
// echo "<tr>";
// echo "<td>".$row['place']."</td>";
// echo "<td>".$row['date']."</td>";
// echo "<td>".$row['price']."</td>";
// echo "</tr>";
// }
$stmt = $conn->prepare("SELECT bookings.id, tours.place, datetour.date, tours.price, numofppl.num_of_people
FROM bookings
JOIN tours ON bookings.tour_id = tours.id
JOIN datetour ON bookings.tour_id = datetour.tour_id
JOIN numofppl ON bookings.tour_id = numofppl.tour_id
WHERE bookings.user_id = :user_id");
$stmt->bindParam(':user_id', $_SESSION['user_id']);
$stmt->execute();
// Fetch the results and display them in the table
while ($row = $stmt->fetch()) {
echo "<tr>";
echo "<td>".$row['id']."</td>";
echo "<td>".$row['place']."</td>";
echo "<td>".$row['date']."</td>";
echo "<td>".$row['price']."</td>";
echo "<td>".$row['num_of_people']."</td>";
echo "<td>".$row['num_of_people']*$row['price']."</td>";
echo "<td><form method='post' action='delete_booking.php'><input type='hidden' name='booking_id' value='".$row['id']."'><input class='btn btn-primary' type='submit' value='Delete'></form></td>";
}
?>
</tbody>
</table>
<?php
} catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
// $conn = null;
?>
</table><br><br>
<div class="btn-group" style="text-align:center;">
<a href="aanew_cards.php" class="btn btn-primary" style="display:block; width:30%; margin:0 auto;">view all tours</a>
<a href="paymentpage.php" class="btn btn-primary" style="display:block; width:30%; margin:0 auto;">continue to payment</a>
</div>
</div>
</body>
</html>