-
Notifications
You must be signed in to change notification settings - Fork 0
/
bookingConfirmation.php
93 lines (79 loc) · 3.84 KB
/
bookingConfirmation.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Booking Page</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php
$CustomerID="";
if(isset($_GET['CustomerID']) && $_GET['CustomerID']!= '') {
$CustomerID=$_GET['CustomerID'];
}
?>
<div class="container">
<nav class="navigation-bar">
<a href="http://localhost/airline/">
<img class="logo" src="logo.png">
</a>
<style>
/* Define a CSS class for the image */
.logo {
width: 30px;
height: auto;
}
</style>
<style>
/* Define a CSS class for the image */
.logo {
width: 30px;
height: auto;
}
</style>
<nav class="nav-links">
<a href="login.php" style="<?= $CustomerID == '' ? 'visibility:visible':'visibility:hidden'?>">Login</a>
<a href="signup.php"style="<?= $CustomerID == '' ? 'visibility:visible':'visibility:hidden'?>">Sign-Up</a>
<a href="account.php?CustomerID=<?=$CustomerID?>"style="<?= $CustomerID == '' ? 'visibility:hidden':'visibility:visible'?>">Profile</a>
</nav>
</nav>
<br><br><br>
<?php
if(isset($_GET['DepartTicket']) && $_GET['DepartTicket']!= ''
&& isset($_GET['CustomerID']) && $_GET['CustomerID']!= '' )
{
$DepartTicket = $_GET['DepartTicket'];
$CustomerID =$_GET['CustomerID'];
$conn = mysqli_connect("localhost", "root", "", "airport_db");
/* check connection */
if (!$conn) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
//randomly generate booking id
$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$bookingID = substr(str_shuffle($characters), 0, 5);
$sql = "INSERT INTO `Bookings` (`BookingID`, `BookingDate`, `customerID`, `TicketID`) VALUES ('$bookingID', CURRENT_DATE(), '$CustomerID', '$DepartTicket');";
$dBookingResult = $conn->query($sql);
if(isset($_GET['ReturnTicket']) && $_GET['ReturnTicket']!= '')
{
$ReturnTicket = $_GET['ReturnTicket'];
$sql = "INSERT INTO `Bookings` (`BookingID`, `BookingDate`, `customerID`, `TicketID`) VALUES ('$bookingID', CURRENT_DATE(), '$CustomerID', '$ReturnTicket');";
$rBookingResult = $conn->query($sql);
}
mysqli_close($conn);
echo "<table class='tableNoBorder'>";
echo "<tr class='trtdNoBorder'><td class='trtdNoBorder'><h1>Congratulations!</h1></td></tr>";
echo "<tr class='trtdNoBorder'><td class='trtdNoBorder'><h2>You have successfully made a booking.</h2></td>";
echo "<tr class='trtdNoBorder'><td class='trtdNoBorder'><h2>Booking ID: ". $bookingID . "</h2></td>";
echo"</table>";
}
else{
echo "Incorrect Information.";
echo "<br/>";
echo "<a href='/airline/index.php'>Click Here</a> to go to Search Flight page.";
}
?>
</div>
</body>
</html>