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 if (isset($_SESSION['return_flight_departure_city'])) $return_flight_departure_city = $_SESSION['return_flight_departure_city'];
14 if (isset($_SESSION['return_flight_arrival_city'])) $return_flight_arrival_city = $_SESSION['return_flight_arrival_city'];
15 if (isset($_SESSION['return_flight_departure_date'])) {
16 $return_flight_departure_date = $_SESSION['return_flight_departure_date'];
17 $oDepartureDate = new DateTime($return_flight_departure_date);
23 <form action
="index.php" id
="search" method
="post">
24 <input type
="hidden" name
="form" value
="search" />
25 <?php
if ($action === "return_flight") echo "<input type=\"hidden\" name=\"action\" value=\"return_flight\" />" ?
>
26 <input type
="hidden" name
="date_now" value
="<?php echo date('Y-m-d\TH:i', time() - 600); ?>" />
27 <label
> De
́part : Ville -> </label>
28 <select size
="1" name
="departure_city" required
>
29 <optgroup label
="Sélectionner une ville">
31 $sql_pquery = "select distinct VilleD from VOLS";
33 $connection->prepare_query($sql_pquery);
34 $connection->run_prepared_query();
35 $connection->get_pquery_result();
36 $cities = $connection->get_result_array();
37 $connection->close_prepared_query();
38 foreach ($cities as $city) {
39 if (strcmp($city[0], $return_flight_departure_city) === 0) {
40 echo "<option value=\"$city[0]\" selected>$city[0]</option>\n";
42 echo "<option value=\"$city[0]\">$city[0]</option>\n";
48 <label
> Date
-> </label
>
49 <input type
="datetime-local" name
="departure_date" value
="<?php echo $oDepartureDate->format('Y-m-d\TH:i'); ?>" required
/>
50 <label
> Arrive
́e : Ville -> </label>
51 <select size
="1" name
="arrival_city" required
>
52 <optgroup label
="Sélectionner une ville">
54 $sql_pquery = "select distinct VilleA from VOLS";
56 $connection->prepare_query($sql_pquery);
57 $connection->run_prepared_query();
58 $connection->get_pquery_result();
59 $cities = $connection->get_result_array();
60 $connection->close_prepared_query();
61 foreach ($cities as $city) {
62 if (strcmp($city[0], $return_flight_arrival_city) === 0) {
63 echo "<option value=\"$city[0]\" selected>$city[0]</option>\n";
65 echo "<option value=\"$city[0]\">$city[0]</option>\n";
71 <label
> Date
-> </label
>
72 <input type
="datetime-local" name
="arrival_date" />
73 <input type
="submit" value
="Rechercher">
78 // Unset all used session variables
79 unset($_SESSION['return_flight_departure_city']);
80 unset($_SESSION['return_flight_arrival_city']);
81 unset($_SESSION['return_flight_departure_date']);