|
|
@ -1,5 +1,7 @@
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Declaration des fonctions
|
|
|
|
|
|
|
|
|
|
|
|
function checkAvis($db, $mail, $codetrajet)
|
|
|
|
function checkAvis($db, $mail, $codetrajet)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$result = pg_query_params($db, "SELECT COUNT(*) FROM avis WHERE mailEmetteur = $1 AND codetrajet = $2;", array($mail, $codetrajet));
|
|
|
|
$result = pg_query_params($db, "SELECT COUNT(*) FROM avis WHERE mailEmetteur = $1 AND codetrajet = $2;", array($mail, $codetrajet));
|
|
|
@ -14,11 +16,14 @@ function checkCodeTrajetAvis($db, $mail, $codetrajet)
|
|
|
|
return $row[0] >= 1;
|
|
|
|
return $row[0] >= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Importation des fichiers necessaires
|
|
|
|
|
|
|
|
|
|
|
|
session_start();
|
|
|
|
session_start();
|
|
|
|
require_once("../connexionBD.php");
|
|
|
|
require_once("../connexionBD.php");
|
|
|
|
require_once("../ressources/user.php");
|
|
|
|
require_once("../ressources/user.php");
|
|
|
|
|
|
|
|
|
|
|
|
//Si on est pas connecté redirection vers la page de connexion
|
|
|
|
//Si on est pas connecté redirection vers la page de connexion
|
|
|
|
|
|
|
|
|
|
|
|
if (!isset($_SESSION['mail'])) {
|
|
|
|
if (!isset($_SESSION['mail'])) {
|
|
|
|
header('Location: ../index.php');
|
|
|
|
header('Location: ../index.php');
|
|
|
|
exit();
|
|
|
|
exit();
|
|
|
@ -26,18 +31,19 @@ if (!isset($_SESSION['mail'])) {
|
|
|
|
|
|
|
|
|
|
|
|
$mail = $_SESSION['mail'];
|
|
|
|
$mail = $_SESSION['mail'];
|
|
|
|
if (isset($_POST['codetrajet']) && isset($_POST['avislaisse']) && isset($_POST['note'])) {
|
|
|
|
if (isset($_POST['codetrajet']) && isset($_POST['avislaisse']) && isset($_POST['note'])) {
|
|
|
|
|
|
|
|
//Recuperation des variables passer par le formulaire
|
|
|
|
$avis = $_POST['avislaisse'];
|
|
|
|
$avis = $_POST['avislaisse'];
|
|
|
|
$note = $_POST['note'];
|
|
|
|
$note = $_POST['note'];
|
|
|
|
$codetrajet = intval($_POST['codetrajet']);
|
|
|
|
$codetrajet = intval($_POST['codetrajet']);
|
|
|
|
$date = date('Y-m-d H:i:s');
|
|
|
|
$date = date('Y-m-d H:i:s');
|
|
|
|
if (checkAvis($db, $mail, $codetrajet) && checkCodeTrajetAvis($db, $mail, $codetrajet)) {
|
|
|
|
if (checkAvis($db, $mail, $codetrajet) && checkCodeTrajetAvis($db, $mail, $codetrajet)) {
|
|
|
|
$requete = "INSERT INTO avis (mailemetteur, codetrajet, commentaire, dateavis, note, estlu) VALUES ($1,$2,$3,$4,$5, false);";
|
|
|
|
$requete = "INSERT INTO avis (mailemetteur, codetrajet, commentaire, dateavis, note, estlu) VALUES ($1,$2,$3,$4,$5, false);"; //Requete d'insertion
|
|
|
|
$envoi = pg_query_params($db, $requete, array($mail, $codetrajet, $avis, $date, $note));
|
|
|
|
$envoi = pg_query_params($db, $requete, array($mail, $codetrajet, $avis, $date, $note)); // Envoie de la requete
|
|
|
|
if (!$envoi) {
|
|
|
|
if (!$envoi) { //Erreur
|
|
|
|
echo "Erreur d'ecriture dans la BD";
|
|
|
|
echo "Erreur d'ecriture dans la BD";
|
|
|
|
echo "<br><a href='../tableauBord/tableauBord.php'>Retour vers le tableau de bord</a>";
|
|
|
|
echo "<br><a href='../tableauBord/tableauBord.php'>Retour vers le tableau de bord</a>";
|
|
|
|
exit();
|
|
|
|
exit();
|
|
|
|
} else {
|
|
|
|
} else { //Redirection en cas de reussite
|
|
|
|
header('Location: ../tableauBord/tableauBord.php');
|
|
|
|
header('Location: ../tableauBord/tableauBord.php');
|
|
|
|
exit();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -56,14 +62,14 @@ if (isset($_POST['codetrajet']) && isset($_POST['avislaisse']) && isset($_POST['
|
|
|
|
<body>
|
|
|
|
<body>
|
|
|
|
<?php require_once("../ressources/navbarhtml.php"); ?>
|
|
|
|
<?php require_once("../ressources/navbarhtml.php"); ?>
|
|
|
|
<div id="container">
|
|
|
|
<div id="container">
|
|
|
|
<div id="entete">
|
|
|
|
<div id="entete"> <--Entete-->
|
|
|
|
<h1 id="titre">Deposer un avis</h1>
|
|
|
|
<h1 id="titre">Deposer un avis</h1>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="form">
|
|
|
|
<div id="form"><--Formulaire-->
|
|
|
|
<form id="formulaire_avis" enctype="multipart/form-data" action="deposer_avis.php" method="post">
|
|
|
|
<form id="formulaire_avis" enctype="multipart/form-data" action="deposer_avis.php" method="post">
|
|
|
|
<textarea id="avis_laisse" name="avislaisse" form="formulaire_avis" placeholder="Avis"></textarea>
|
|
|
|
<textarea id="avis_laisse" name="avislaisse" form="formulaire_avis" placeholder="Avis"></textarea> <--Champ_de_saisie_d_avis-->
|
|
|
|
<h2>NOTE</h2>
|
|
|
|
<h2>NOTE</h2>
|
|
|
|
<div class="rating">
|
|
|
|
<div class="rating"><--Bouton_note-->
|
|
|
|
<input type="radio" name="note" id="note3" value="3">
|
|
|
|
<input type="radio" name="note" id="note3" value="3">
|
|
|
|
<a href="#3" label for="note3" title="Donner 3 étoiles">☆</a>
|
|
|
|
<a href="#3" label for="note3" title="Donner 3 étoiles">☆</a>
|
|
|
|
<input type="radio" name="note" id="note2" value="2">
|
|
|
|
<input type="radio" name="note" id="note2" value="2">
|
|
|
@ -78,7 +84,7 @@ if (isset($_POST['codetrajet']) && isset($_POST['avislaisse']) && isset($_POST['
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
<input type="submit" value="Valider" id="submit">
|
|
|
|
<input type="submit" value="Valider" id="submit"><--Envoie-->
|
|
|
|
</form>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|