Commentaire code
parent
508c84a04f
commit
13064316fd
@ -1,86 +1,92 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function checkAvis($db, $mail, $codetrajet)
|
//Declaration des fonctions
|
||||||
{
|
|
||||||
$result = pg_query_params($db, "SELECT COUNT(*) FROM avis WHERE mailEmetteur = $1 AND codetrajet = $2;", array($mail, $codetrajet));
|
function checkAvis($db, $mail, $codetrajet)
|
||||||
$row = pg_fetch_array($result);
|
{
|
||||||
return $row[0] == 0;
|
$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));
|
function checkCodeTrajetAvis($db, $mail, $codetrajet)
|
||||||
$row = pg_fetch_array($result);
|
{
|
||||||
return $row[0] >= 1;
|
$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;
|
||||||
session_start();
|
}
|
||||||
require_once("../connexionBD.php");
|
|
||||||
require_once("../ressources/user.php");
|
//Importation des fichiers necessaires
|
||||||
|
|
||||||
//Si on est pas connecté redirection vers la page de connexion
|
session_start();
|
||||||
if (!isset($_SESSION['mail'])) {
|
require_once("../connexionBD.php");
|
||||||
header('Location: ../index.php');
|
require_once("../ressources/user.php");
|
||||||
exit();
|
|
||||||
}
|
//Si on est pas connecté redirection vers la page de connexion
|
||||||
|
|
||||||
$mail = $_SESSION['mail'];
|
if (!isset($_SESSION['mail'])) {
|
||||||
if (isset($_POST['codetrajet']) && isset($_POST['avislaisse']) && isset($_POST['note'])) {
|
header('Location: ../index.php');
|
||||||
$avis = $_POST['avislaisse'];
|
exit();
|
||||||
$note = $_POST['note'];
|
}
|
||||||
$codetrajet = intval($_POST['codetrajet']);
|
|
||||||
$date = date('Y-m-d H:i:s');
|
$mail = $_SESSION['mail'];
|
||||||
if (checkAvis($db, $mail, $codetrajet) && checkCodeTrajetAvis($db, $mail, $codetrajet)) {
|
if (isset($_POST['codetrajet']) && isset($_POST['avislaisse']) && isset($_POST['note'])) {
|
||||||
$requete = "INSERT INTO avis (mailemetteur, codetrajet, commentaire, dateavis, note, estlu) VALUES ($1,$2,$3,$4,$5, false);";
|
//Recuperation des variables passer par le formulaire
|
||||||
$envoi = pg_query_params($db, $requete, array($mail, $codetrajet, $avis, $date, $note));
|
$avis = $_POST['avislaisse'];
|
||||||
if (!$envoi) {
|
$note = $_POST['note'];
|
||||||
echo "Erreur d'ecriture dans la BD";
|
$codetrajet = intval($_POST['codetrajet']);
|
||||||
echo "<br><a href='../tableauBord/tableauBord.php'>Retour vers le tableau de bord</a>";
|
$date = date('Y-m-d H:i:s');
|
||||||
exit();
|
if (checkAvis($db, $mail, $codetrajet) && checkCodeTrajetAvis($db, $mail, $codetrajet)) {
|
||||||
} else {
|
$requete = "INSERT INTO avis (mailemetteur, codetrajet, commentaire, dateavis, note, estlu) VALUES ($1,$2,$3,$4,$5, false);"; //Requete d'insertion
|
||||||
header('Location: ../tableauBord/tableauBord.php');
|
$envoi = pg_query_params($db, $requete, array($mail, $codetrajet, $avis, $date, $note)); // Envoie de la requete
|
||||||
exit();
|
if (!$envoi) { //Erreur
|
||||||
}
|
echo "Erreur d'ecriture dans la BD";
|
||||||
}
|
echo "<br><a href='../tableauBord/tableauBord.php'>Retour vers le tableau de bord</a>";
|
||||||
}
|
exit();
|
||||||
?>
|
} else { //Redirection en cas de reussite
|
||||||
<!DOCTYPE html>
|
header('Location: ../tableauBord/tableauBord.php');
|
||||||
<html lang="fr">
|
exit();
|
||||||
<head>
|
}
|
||||||
<meta charset="UTF-8">
|
}
|
||||||
<link rel="stylesheet" href="deposer_avis.css">
|
}
|
||||||
<link rel="stylesheet" href="../ressources/navbarhtml.css">
|
?>
|
||||||
<link rel="icon" href="../ressources/favicon.ico"/>
|
<!DOCTYPE html>
|
||||||
<title>Deposer un avis</title>
|
<html lang="fr">
|
||||||
</head>
|
<head>
|
||||||
<body>
|
<meta charset="UTF-8">
|
||||||
<?php require_once("../ressources/navbarhtml.php"); ?>
|
<link rel="stylesheet" href="deposer_avis.css">
|
||||||
<div id="container">
|
<link rel="stylesheet" href="../ressources/navbarhtml.css">
|
||||||
<div id="entete">
|
<link rel="icon" href="../ressources/favicon.ico"/>
|
||||||
<h1 id="titre">Deposer un avis</h1>
|
<title>Deposer un avis</title>
|
||||||
</div>
|
</head>
|
||||||
<div id="form">
|
<body>
|
||||||
<form id="formulaire_avis" enctype="multipart/form-data" action="deposer_avis.php" method="post">
|
<?php require_once("../ressources/navbarhtml.php"); ?>
|
||||||
<textarea id="avis_laisse" name="avislaisse" form="formulaire_avis" placeholder="Avis"></textarea>
|
<div id="container">
|
||||||
<h2>NOTE</h2>
|
<div id="entete"> <--Entete-->
|
||||||
<div class="rating">
|
<h1 id="titre">Deposer un avis</h1>
|
||||||
<input type="radio" name="note" id="note3" value="3">
|
</div>
|
||||||
<a href="#3" label for="note3" title="Donner 3 étoiles">☆</a>
|
<div id="form"><--Formulaire-->
|
||||||
<input type="radio" name="note" id="note2" value="2">
|
<form id="formulaire_avis" enctype="multipart/form-data" action="deposer_avis.php" method="post">
|
||||||
<a href="#2" label for="note2" title="Donner 2 étoiles">☆</a>
|
<textarea id="avis_laisse" name="avislaisse" form="formulaire_avis" placeholder="Avis"></textarea> <--Champ_de_saisie_d_avis-->
|
||||||
<input type="radio" name="note" id="note1" value="1">
|
<h2>NOTE</h2>
|
||||||
<a href="#1" label for="note1" title="Donner 1 étoiles">☆</a>
|
<div class="rating"><--Bouton_note-->
|
||||||
<?php
|
<input type="radio" name="note" id="note3" value="3">
|
||||||
if (isset($_GET['codetrajet'])) {
|
<a href="#3" label for="note3" title="Donner 3 étoiles">☆</a>
|
||||||
$codeTrajet = $_GET['codetrajet'];
|
<input type="radio" name="note" id="note2" value="2">
|
||||||
echo "<input type='hidden' name='codetrajet' value='$codeTrajet'>";
|
<a href="#2" label for="note2" title="Donner 2 étoiles">☆</a>
|
||||||
}
|
<input type="radio" name="note" id="note1" value="1">
|
||||||
?>
|
<a href="#1" label for="note1" title="Donner 1 étoiles">☆</a>
|
||||||
</div>
|
<?php
|
||||||
<br>
|
if (isset($_GET['codetrajet'])) {
|
||||||
<input type="submit" value="Valider" id="submit">
|
$codeTrajet = $_GET['codetrajet'];
|
||||||
</form>
|
echo "<input type='hidden' name='codetrajet' value='$codeTrajet'>";
|
||||||
</div>
|
}
|
||||||
</div>
|
?>
|
||||||
</body>
|
</div>
|
||||||
</html>
|
<br>
|
||||||
|
<input type="submit" value="Valider" id="submit"><--Envoie-->
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
Loading…
Reference in New Issue