-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview_flights_form_handler.php
213 lines (210 loc) · 6.14 KB
/
view_flights_form_handler.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
<?php
session_start();
?>
<html>
<head>
<title>
View Available Flights
</title>
<style>
input {
border: 1.5px solid #030337;
border-radius: 4px;
padding: 7px 30px;
}
input[type=submit] {
background-color: #030337;
color: white;
border-radius: 4px;
padding: 7px 45px;
margin: 0px 390px
}
table {
border-collapse: collapse;
}
tr/*:nth-child(3)*/ {
border: solid thin;
}
</style>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<link rel="stylesheet" href="font-awesome-4.7.0\css\font-awesome.min.css">
</head>
<body>
<img class="logo" src="images/shutterstock_22.jpg"/>
<h1 id="title">
AADITH AIRLINES
</h1>
<div>
<ul>
<li><a href="home_page.php"><i class="fa fa-home" aria-hidden="true"></i> Home</a></li>
<li><a href="customer_homepage.php"><i class="fa fa-desktop" aria-hidden="true"></i> Dashboard</a></li>
<li><a href="home_page.php"><i class="fa fa-plane" aria-hidden="true"></i> About Us</a></li>
<li><a href="home_page.php"><i class="fa fa-phone" aria-hidden="true"></i> Contact Us</a></li>
<li><a href="logout_handler.php"><i class="fa fa-sign-out" aria-hidden="true"></i> Logout</a></li>
</ul>
</div>
<h2>AVAILABLE FLIGHTS</h2>
<?php
if(isset($_POST['Search']))
{
$data_missing=array();
if(empty($_POST['origin']))
{
$data_missing[]='Origin';
}
else
{
$origin=$_POST['origin'];
}
if(empty($_POST['destination']))
{
$data_missing[]='Destination';
}
else
{
$destination=$_POST['destination'];
}
if(empty($_POST['dep_date']))
{
$data_missing[]='Departure Date';
}
else
{
$dep_date=trim($_POST['dep_date']);
}
if(empty($_POST['no_of_pass']))
{
$data_missing[]='No. of Passengers';
}
else
{
$no_of_pass=trim($_POST['no_of_pass']);
}
if(empty($_POST['class']))
{
$data_missing[]='Class';
}
else
{
$class=trim($_POST['class']);
}
if(empty($data_missing))
{
$_SESSION['no_of_pass']=$no_of_pass;
$_SESSION['class']=$class;
$count=1;
$_SESSION['count']=$count;
$_SESSION['journey_date']=$dep_date;
require_once('Database Connection file/mysqli_connect.php');
if($class=="economy")
{
$query="SELECT flight_no,from_city,to_city,departure_date,departure_time,arrival_date,arrival_time,price_economy FROM Flight_Details where from_city=? and to_city=? and departure_date=? and seats_economy>=? ORDER BY departure_time";
$stmt=mysqli_prepare($dbc,$query);
mysqli_stmt_bind_param($stmt,"sssi",$origin,$destination,$dep_date,$no_of_pass);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt,$flight_no,$from_city,$to_city,$departure_date,$departure_time,$arrival_date,$arrival_time,$price_economy);
mysqli_stmt_store_result($stmt);
if(mysqli_stmt_num_rows($stmt)==0)
{
echo "<h3>No flights are available !</h3>";
}
else
{
echo "<form action=\"book_tickets2.php\" method=\"post\">";
echo "<table cellpadding=\"10\"";
echo "<tr><th>Flight No.</th>
<th>Origin</th>
<th>Destination</th>
<th>Departure Date</th>
<th>Departure Time</th>
<th>Arrival Date</th>
<th>Arrival Time</th>
<th>Price(Economy)</th>
<th>Select</th>
</tr>";
while(mysqli_stmt_fetch($stmt)) {
echo "<tr>
<td>".$flight_no."</td>
<td>".$from_city."</td>
<td>".$to_city."</td>
<td>".$departure_date."</td>
<td>".$departure_time."</td>
<td>".$arrival_date."</td>
<td>".$arrival_time."</td>
<td>₹ ".$price_economy."</td>
<td><input type=\"radio\" name=\"select_flight\" value=\"".$flight_no."\"></td>
</tr>";
}
echo "</table> <br>";
echo "<input type=\"submit\" value=\"Select Flight\" name=\"Select\">";
echo "</form>";
}
}
else if($class="business")
{
$query="SELECT flight_no,from_city,to_city,departure_date,departure_time,arrival_date,arrival_time,price_business FROM Flight_Details where from_city=? and to_city=? and departure_date=? and seats_business>=? ORDER BY departure_time";
$stmt=mysqli_prepare($dbc,$query);
mysqli_stmt_bind_param($stmt,"sssi",$origin,$destination,$dep_date,$no_of_pass);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt,$flight_no,$from_city,$to_city,$departure_date,$departure_time,$arrival_date,$arrival_time,$price_business);
mysqli_stmt_store_result($stmt);
if(mysqli_stmt_num_rows($stmt)==0)
{
echo "<h3>No flights are available !</h3>";
}
else
{
echo "<form action=\"book_tickets2.php\" method=\"post\">";
echo "<table cellpadding=\"10\"";
echo "<tr><th>Flight No.</th>
<th>Origin</th>
<th>Destination</th>
<th>Departure Date</th>
<th>Departure Time</th>
<th>Arrival Date</th>
<th>Arrival Time</th>
<th>Price(Business)</th>
<th>Select</th>
</tr>";
while(mysqli_stmt_fetch($stmt)) {
echo "<tr>
<td>".$flight_no."</td>
<td>".$from_city."</td>
<td>".$to_city."</td>
<td>".$departure_date."</td>
<td>".$departure_time."</td>
<td>".$arrival_date."</td>
<td>".$arrival_time."</td>
<td>₹ ".$price_business."</td>
<td><input type=\"radio\" name=\"select_flight\" value=".$flight_no."></td>
</tr>";
}
echo "</table> <br>";
echo "<input type=\"submit\" value=\"Select Flight\" name=\"Select\">";
echo "</form>";
}
}
mysqli_stmt_close($stmt);
mysqli_close($dbc);
// else
// {
// echo "Submit Error";
// echo mysqli_error();
// }
}
else
{
echo "The following data fields were empty! <br>";
foreach($data_missing as $missing)
{
echo $missing ."<br>";
}
}
}
else
{
echo "Search request not received";
}
?>
</body>
</html>