$result = pg_query_params($db, "SELECT COUNT(*) FROM avis WHERE mailEmetteur = $1 AND codetrajet = $2;", array($mail, $codetrajet));
$row = pg_fetch_array($result);
return $row[0] == 0;
}
function checkCodeTrajetAvis($db, $mail, $codetrajet)
{
$result = pg_query_params($db, "SELECT COUNT(*) FROM trajet tr, reserver re WHERE tr.codetrajet = $1 AND tr.codetrajet = re.codetrajet AND re.mailutilisateur = $2;", array($codetrajet, $mail));
$row = pg_fetch_array($result);
return $row[0] >= 1;
}
//Importation des fichiers necessaires
session_start();
require_once("../connexionBD.php");
require_once("../ressources/user.php");
//Si on est pas connecté redirection vers la page de connexion
if (!isset($_SESSION['mail'])) {
header('Location: ../index.php');
exit();
}
$mail = $_SESSION['mail'];
if (isset($_POST['codetrajet']) && isset($_POST['avislaisse']) && isset($_POST['note'])) {
//Recuperation des variables passer par le formulaire
$avis = $_POST['avislaisse'];
$note = $_POST['note'];
$codetrajet = intval($_POST['codetrajet']);
$date = date('Y-m-d H:i:s');
if (checkAvis($db, $mail, $codetrajet) && checkCodeTrajetAvis($db, $mail, $codetrajet)) {