booking_page.php
8.79 KB
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>index</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="css2.css">
<script defer src="mainjs.js"></script>
<style>
.container {
max-width: 600px;
margin: 0 auto;
position: relative;
}
#search input[type="departure"],
#search input[type="arrival"],
#search input[type="class"],
#search input[type="date"],
#search input[type="date"],
#search input[type="filters"],
#search button[type="submit"] {
font: 400 12px/16px "Roboto", Helvetica, Arial, sans-serif;
}
#search {
background: #F9F9F9;
padding: 25px;
margin: 15px 0;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
}
#search h3 {
display: block;
font-size: 30px;
font-weight: 300;
margin-bottom: 10px;
}
#search h4 {
margin: 5px 0 15px;
display: block;
font-size: 13px;
font-weight: 400;
}
fieldset {
border: medium none !important;
margin: 0 0 10px;
min-width: 100%;
padding: 0;
width: 100%;
}
#search input[type="departure"],
#search input[type="arrival"],
#search input[type="class"],
#search input[type="date"],
#search input[type="date"],
#search input[type="filters"] {
width: 100%;
border: 1px solid #ccc;
background: #FFF;
margin: 0 0 5px;
padding: 10px;
}
#search input[type="departure"]:hover,
#search input[type="arrival"]:hover,
#search input[type="class"],
#search input[type="date"]:hover,
#search input[type="date"]:hover,
#search input[type="filters"]:hover {
-webkit-transition: border-color 0.3s ease-in-out;
-moz-transition: border-color 0.3s ease-in-out;
transition: border-color 0.3s ease-in-out;
border: 1px solid #aaa;
}
#search button[type="submit"] {
cursor: pointer;
width: 100%;
border: none;
background: #4CAF50;
color: #FFF;
margin: 0 0 5px;
padding: 10px;
font-size: 20px;
}
#search button[type="submit"]:hover {
background: #43A047;
-webkit-transition: background 0.3s ease-in-out;
-moz-transition: background 0.3s ease-in-out;
transition: background-color 0.3s ease-in-out;
}
#search button[type="submit"]:active {
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}
#search input:focus,
#search textarea:focus {
outline: 0;
border: 1px solid #aaa;
}
</style>
</head>
<body>
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="countrypage.html">Countries</a></li>
<li><a class="active" href="booking_page.php">Booking</a></li>
<li><a href="contact.php">Contact</a></li>
<li><a href="user_login.php">Login</a></li>
<li><a href="loginform_for_admin_2.php">Admin login</a></li>
<li><a href="countrypage.html">Countries</a></li>
</ul>
<div class="row">
<div class="container">
<fieldset>
<form id="search" method="post" action="<?php $PHP_SELF?>">
<legend><h1>You may search your flights details</h1></legend>
<legend>Please enter your departure and arrival point:</legend>
<br>
<label for="departure">departure: </label>
<input id="departure" placeholder="departure" type="departure" name="departure" tabindex="1" required autofocus style="text-transform:uppercase" />
<br>
<label for="arrival">arrival: </label>
<input id="arrival" placeholder="arrival" type="arrival" name="arrival" tabindex="2" required required autofocus style="text-transform:uppercase" />
<br>
<legend>Please select your class:</legend>
<select>
<option type="class" value="economy">Economy</option>
<option type="class" value="business">Business</option>
<option type="class" value="first">First</option>
</select>
<br>
<legend>Please select your date:</legend>
<label for="start">Start: </label>
<input type="date" id="start" name="trip_going" value="yyyy-mm-dd" min="2018-01-01" max="9000-12-21" />
<br>
<label for="end">End: </label>
<input type="date" id="end" name="trip_back" value="yyyy-mm-dd" min="2018-01-01" max="9000-12-21" />
<br>
<legend>Filter:</legend>
<input type="checkbox" name="check_list[]" value="Morning"><label>Morning</label><br/>
<input type="checkbox" name="check_list[]" value="Afternoon"><label>Afternoon</label><br/>
<input type="checkbox" name="check_list[]" value="Night"><label>Night</label><br/>
<!-- <legend>Cost filter:</legend>
<input type="radio" name="radio_list[]" value="htolcost"><label>Hight to low cost</label><br/>
<input type="radio" name="radio_list[]" value="ltohcost"><label>Low to high cost</label><br/> -->
<!-- <input type="radio" name="cost_order_high_to_low" value="TRUE" checked>TRUE
<input type="radio" name="cost_order_high_to_low" value="FALSE">FALSE
<input type="radio" name="cost_order_low_to_high" value="TRUE" checked>TRUE
<input type="radio" name="cost_order_low_to_high" value="FALSE">FALSE -->
<legend>Cost Filter</legend>
<input name="radio" type="radio" value="htolcost">Hight to low cost
<br>
<input name="radio" type="radio" value="ltohcost">Low to high cost
<br>
<input type="hidden" name="flight_search" value="yes" />
<input type="submit" name="submit" class="button7" value="Search" />
</form>
<?php
//This is only displayed if the user submitted the form
if (isset($_POST['flight_search'])){
echo "<h2>Results</h2><p>";
//If the user did not enter a search term, they receive an error
if ($_POST['departure'] and $_POST['arrival']== ""){
echo "<p>Please enter a search term";
exit;
}
// Otherwise we connect to the database
$con = mysqli_connect("anysql.itcollege.ee", "WT16", "iLtQlUerkT", "WT16");
// Check connection
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$departure = ($_POST["departure"]);
$arrival = ($_POST["arrival"]);
$date_going = ($_POST["trip_going"]);
$date_back = ($_POST["trip_back"]);
}
//echo "$departure";
//echo "$arrival";
//Now we search for our search term, in the field the user specified
//if Morning_AfterNoon_Night = Morning
//$data = mysqli_query($con, "SELECT * FROM FlightData WHERE departure = '$departure' AND arrival = '$arrival'");
$int = 0;
foreach ($_POST['check_list'] as $select){
if ($int > 0){
$filter = $filter . " or Morning_AfterNoon_Night ='" . $select . "'" ;
}
else {
$filter = " and Morning_AfterNoon_Night ='" . $select . "'" ;
}
$int = $int + 1;
}
//$a = $a . ")";
if(isset($_POST['radio'])){
echo "You have selected :".$_POST['radio'];
}
if ($_POST['radio'] === 'htolcost'){
$order = " ORDER BY Price DESC" ;
}
else {
$order = " ORDER BY Price" ;
}
//echo "SELECT * FROM FlightData WHERE departure = '$departure' AND arrival = '$arrival' " . "$a";
//$data = mysqli_query($con, "SELECT * FROM FlightData WHERE departure = '$departure' AND arrival = '$arrival'");
$data = mysqli_query($con, "SELECT * FROM FlightData WHERE departure = '$departure' AND arrival = '$arrival' " . "$filter" . "$order");
//And display the results
while($row = mysqli_fetch_array( $data )){
echo "$row[1]". " " ."$row[2]". " " . "$row[3]". " " . "$row[4]". " " . "$row[5]". " " . "$row[6]". " " . "$row[7]". " " . "$row[8]". " " . "$row[9]" . " " . "$date_going". " " . "$date_back". " " ."<a href='loginform2.php?Flight_Id=$row[0]' >". "SELECT" ."</a>";
echo "<br>";
}
//This counts the number or results. If there aren't any, it gives the user a "no match" message
$anymatches=mysqli_num_rows($data);
if ($anymatches == 0){
echo "Sorry, but we can not find an entry to match your query<br><br>";
}
//And reminds the user what they searched for
echo "<b>Searched For:</b> " . "$find";
}
//break;
if (isset($_GET['Flight_Id#'])) {
$Flight_Id = $_GET['Flight_Id'];
echo $Flight_Id;
}
?>
</fieldset>
</div>
</div>
</body>
</html>