global $is_logged_in;
if (!$is_logged_in) {
echo "Please login first. <br>";
+ $_SESSION['login_referer'] = $_SERVER['HTTP_REFERER'];
redirect("index.php?page=login", 2);
}
$input_failure = true;
}
-if (!$form_return_flight) {
+if (is_null($form_return_flight)) {
+ $form_return_flight = false;
+} elseif (!$form_return_flight) {
echo "Vol retour invalide. <br>";
$input_failure = true;
}
if (!$input_failure && $is_logged_in && !empty($form_nb_place) && !empty($form_class_name)) {
global $connection;
$client_id = get_client_id($_SESSION['email']);
- $nb_booked = nb_booked($client_id, $form_flight_id);
+ $nb_booked = nb_booked($client_id, $form_flight_id, $form_class_name);
if (!empty($nb_booked)) {
echo "Vous avez déjà réservé ce vol, vous allez être redirigé vers la liste de vos réservations dans 2 secondes. <br>";
redirect("index.php?page=reservations", 2);
$rows = $connection->get_result_array();
$connection->close_prepared_query();
foreach ($rows as $row) {
- echo "(Simulation de paiement d'une réservation) <br>";
+ echo "(Simulation de validation et paiement d'une réservation) <br>";
echo "Vous avez réservé et payé " . $form_nb_place . " place(s) sur le vol " .$form_flight_id .
" au départ de " . $row['VilleD']. " à " . $row['DateD'] . " arrivant à " . $row['VilleA'] . " à " . $row['DateA'] .
" pour un montant total de " . $form_place_price * $form_nb_place . "€. <br>";
}
if ($form_return_flight) {
- redirect("index.php?page=search", 3);
- $_SESSION['current_flight_id'] = $form_flight_id;
- $_SESSION['return_flight'] = $form_return_flight;
+ $_SESSION['return_flight_departure_city'] = $row['VilleA'];
+ $_SESSION['return_flight_arrival_city'] = $row['VilleD'];
+ $_SESSION['return_flight_departure_date'] = $row['DateA'];
+ redirect("index.php?page=search&action=return_flight", 3);
} else {
redirect("index.php?page=reservations", 3);
}