2 $action = filter_input(INPUT_GET
, "action", FILTER_SANITIZE_STRING
);
4 <h1
> Rechercher un vol
<?php
if ($action === "return_flight") { echo "retour"; } ?
></h1
>
8 $return_flight_departure_city = "";
9 $return_flight_arrival_city = "";
10 $return_flight_departure_date = "";
11 $oDepartureDate = new DateTime("now");
12 if ($action === "return_flight") {
13 //var_dump($_SESSION);
14 if (isset($_SESSION['return_flight_departure_city'])) $return_flight_departure_city = $_SESSION['return_flight_departure_city'];
15 if (isset($_SESSION['return_flight_arrival_city'])) $return_flight_arrival_city = $_SESSION['return_flight_arrival_city'];
16 if (isset($_SESSION['return_flight_departure_date'])) {
17 $return_flight_departure_date = $_SESSION['return_flight_departure_date'];
18 $oDepartureDate = new DateTime($return_flight_departure_date);
24 <form action
="index.php" id
="search" method
="post">
25 <input type
="hidden" name
="form" value
="search" />
26 <?php
if ($action === "return_flight") echo "<input type=\"hidden\" name=\"action\" value=\"return_flight\" />" ?
>
27 <input type
="hidden" name
="date_now" value
="<?php echo date('Y-m-d\TH:i', time() - 600); ?>" />
28 <label
> De
́part : Ville -> </label>
29 <select size
="1" name
="departure_city" required
>
30 <optgroup label
="Sélectionner une ville">
32 $sql_pquery = "select distinct VilleD from VOLS";
34 $connection->prepare_query($sql_pquery);
35 $connection->run_prepared_query();
36 $connection->get_pquery_result();
37 $cities = $connection->get_result_array();
38 $connection->close_prepared_query();
39 foreach ($cities as $city) {
40 if (strcmp($city[0], $return_flight_departure_city) === 0) {
41 echo "<option value=\"$city[0]\" selected>$city[0]</option>\n";
43 echo "<option value=\"$city[0]\">$city[0]</option>\n";
49 <label
> Date
-> </label
>
50 <input type
="datetime-local" name
="departure_date" value
="<?php echo $oDepartureDate->format('Y-m-d\TH:i'); ?>" required
/>
51 <label
> Arrive
́e : Ville -> </label>
52 <select size
="1" name
="arrival_city" required
>
53 <optgroup label
="Sélectionner une ville">
55 $sql_pquery = "select distinct VilleA from VOLS";
57 $connection->prepare_query($sql_pquery);
58 $connection->run_prepared_query();
59 $connection->get_pquery_result();
60 $cities = $connection->get_result_array();
61 $connection->close_prepared_query();
62 foreach ($cities as $city) {
63 if (strcmp($city[0], $return_flight_arrival_city) === 0) {
64 echo "<option value=\"$city[0]\" selected>$city[0]</option>\n";
66 echo "<option value=\"$city[0]\">$city[0]</option>\n";
72 <label
> Date
-> </label
>
73 <input type
="datetime-local" name
="arrival_date" />
74 <input type
="submit" value
="Rechercher">
79 // Unset all used session variables
80 unset($_SESSION['return_flight_departure_city']);
81 unset($_SESSION['return_flight_arrival_city']);
82 unset($_SESSION['return_flight_departure_date']);