You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PROJET-WEB_STRI1A/WEB/liste_trajets/reserver.php

38 lines
921 B
PHP

<?php
session_start();
function verifierTrajet($db, $mail, $codetrajet){
$trajet = getTrajet($db, $codetrajet);
if (!$trajet){
return false;
}
$trajet = pg_fetch_array($trajet);
if (strcmp($mail, $trajet['mailproposition']) == 0){
return false;
}
return checkReservations($db, $mail, $codetrajet) && checkPlacesVoiture($db, $codetrajet);
}
require_once("../connexionBD.php");
require_once("../ressources/trajet.php");
if (!isset($_SESSION['mail'])) {
header('Location: ../index.php');
exit();
}
$mail = $_SESSION['mail'];
if (isset($_GET['codetrajet'])){
$codetrajet = $_GET['codetrajet'];
if (verifierTrajet($db, $mail, $codetrajet) && reserver($db, $mail, $codetrajet)){
header('Location: ../tableauBord/tableauBord.php');
exit();
}
else{
header('Location: ../recherche/recherche.php?error=1');
exit();
}
}
?>