-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbook_ticketsee.php
288 lines (251 loc) · 8.31 KB
/
book_ticketsee.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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<?php
require_once('db_connect.php'); // Include your database connection
$success = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$flight_no = $_POST["flight_no"];
$name = $_POST["name"];
$email = $_POST["email"];
$phone = $_POST["phone"];
// Validate flight number
$flight_query = "SELECT * FROM flight_details WHERE flight_no = '$flight_no'";
$flight_result = mysqli_query($conn, $flight_query);
if (mysqli_num_rows($flight_result) == 0) {
$error_message0 = "Flight number $flight_no doesn't exist";
} else {
// Check if booking already exists for the same flight and passenger
$existing_booking_query = "SELECT * FROM bookings WHERE flight_no = '$flight_no' AND name = '$name'";
$existing_booking_result = mysqli_query($conn, $existing_booking_query);
if (mysqli_num_rows($existing_booking_result) > 0) {
$error_message1 = "A booking for this flight and passenger already exists";
} else {
// Insert booking data
$insert_query = "INSERT INTO bookings (flight_no, name, email, phone)
VALUES ('$flight_no', '$name', '$email', '$phone')";
if (mysqli_query($conn, $insert_query)) {
$success = "Flight Successfully Booked";
} else {
$error_message2 = "Booking failed";
}
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600&display=swap" rel="stylesheet">
<title>Book a Ticket</title>
<style>
/* Your updated CSS styles here */
body {
margin: 0;
overflow: hidden;
background: linear-gradient(45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
background-size: 400% 400%;
animation: gradient 15s infinite;
font-family: 'Open Sans', sans-serif;
}
@keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
/* Additional styles for the content */
header, nav, section, footer {
padding: 15px;
}
header {
color: #FFFFF0;
text-align: center;
border: none;
font-weight: bold;
}
header h1 {
font-size: 30px;
margin-bottom: 5px;
color: blue;
font-weight: bold;
}
.logo-option {
display: flex;
align-items: center;
justify-content: center;
}
.logo-option img {
width: 80px;
margin-right: 10px;
}
.logo {
font-size: 20px;
}
.logo-img:hover {
transform: scale(1.1);
transition: transform 0.5s ease;
}
.logo-img:not(:hover) {
transform: scale(1);
transition: transform 0.5s ease;
}
.top-right-options {
position: absolute;
top: 15px;
right: 15px;
display: flex;
align-items: center;
}
.top-right-options a {
text-decoration: none;
color: #333; /* Dark gray color */
margin-right: 10px;
font-weight: bold;
transition: color 0.3s ease, background-color 0.3s ease;
padding: 5px 10px;
border-radius: 5px;
}
.top-right-options a:hover {
color: #FFFFF0; /* Change to text color */
background-color: #333; /* Dark gray color */
}
nav ul {
list-style: none;
}
nav li {
display: inline;
margin-right: 20px;
}
nav a {
text-decoration: none;
color: #FFFFF0;
margin-right: 10px;
font-weight: bold;
transition: color 0.3s ease, background-color 0.3s ease;
padding: 5px 10px;
border-radius: 5px;
transition: color 0.3s ease, background-color 0.3s ease;
}
nav a:hover {
color: #333;
background-color: #FFFFF0;
}
.content {
background-color: #FFFFF0;
padding: 40px;
text-align: center;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
border-radius: 10px;
}
.content h2 {
color: #333;
margin-bottom: 20px;
}
.content label {
display: block;
font-weight: bold;
margin-bottom: 5px;
}
.content input {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
}
.submit-button {
background-color: #e73c7e;
color: #FFFFF0;
border: none;
padding: 10px 20px;
border-radius: 5px;
font-weight: bold;
cursor: pointer;
transition: background-color 0.3s ease, color 0.3s ease;
}
.submit-button:hover {
background-color: #333;
color: #FFFFF0;
}
footer {
background-color: #333;
color: #FFFFF0;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
left: 0;
right: 0;
}
</style>
</head>
<body>
<div class="top-right-options">
<a href="SignOut.php">Sign Out</a>
<a href="#"><?php
if (isset($_SESSION['USER'])) {
echo "Welcome, " . $_SESSION['USER'] . "!";
} else {
echo "You are not logged in.";
}
?>
</a>
</div>
<header>
<div class="logo-option">
<a href="https://www.cristianoronaldo.com/brands">
<img src="cr7logo.png" alt="Logo" class="logo-img">
</a>
<div class="logo">CR7 Airlines</div>
</div>
</header>
<nav>
<ul>
<li><a href="homepage.php">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<section class="content">
<h2><u>Book Your Flight</u></h2>
<form method="post" action="">
<label for="flight_no">Desired Flight Number:</label>
<input type="number" name="flight_no" required><br>
<label for="name">Passenger Name:</label>
<input type="text" name="name" required><br>
<label for="email">Passenger Email:</label>
<input type="email" name="email" required><br>
<label for="phone">Passenger Phone:</label>
<input type="text" name="phone" required><br>
<button class="submit-button" type="submit">Proceed To Payment</button>
<?php
if (isset($success)) {
echo "<p style='color:#333;'>$success</p>";
}
if (isset($error_message0)) {
echo "<p style='color:#333;'>$error_message0</p>";
}
if (isset($error_message1)) {
echo "<p style='color:#333;'>$error_message1</p>";
}
if (isset($error_message2)) {
echo "<p style='color:#333;'>$error_message2</p>";
}
?>
</form>
<form action="book_tickets2.php" method="get">
<button type="submit" class="submit-button"><b>Go Back To Flight Searching</b></button>
</form>
</section>
<footer>
<p>© <?php echo date("Y"); ?> CR7 Airlines</p>
</footer>
</body>
</html>