commit histoire de pas tout perdre

avisTrajet
remi.biette 6 years ago
parent 58e5e866a9
commit 4eafe9558d

@ -7,9 +7,9 @@ Page CSS : avis_laisses.css
body { body {
color:black; color:black;
background-color:white; background-color:white;
background-image:url(../resources/background.jpg); background-image:url("../ressources/image/background.jpg");
background-repeat:no-repeat; background-repeat:no-repeat;
background-size:104%; background-size:100%;
margin: 0; margin: 0;
font-family: Ubuntu,Helvetica,sans-serif; font-family: Ubuntu,Helvetica,sans-serif;
} }
@ -40,7 +40,7 @@ h2{
height:50px; height:50px;
} }
#avis_tab{ .avis_tab{
width:85%; width:85%;
padding-left:15%; padding-left:15%;
} }

@ -1,7 +1,7 @@
<?php <?php
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'])) {
@ -12,18 +12,8 @@ $mail = $_SESSION['mail'];
$login = getLogin($db,$mail); $login = getLogin($db,$mail);
$requete_commentaire = "SELECT commentaire FROM Avis WHERE Avis.mail = $mail"; $requete = "SELECT DISTINCT Utilisateur.login, Avis.commentaire, Avis.dateavis, Avis.note FROM Utilisateur, Avis, Trajet WHERE Avis.mailemetteur = $1 AND Avis.mailemetteur = Utilisateur.mail;";
$requete_dateAvis = "SELECT dateAvis FROM Avis WHERE Avis.mail = $mail"; $result = pg_query_params($db, $requete, array($mail));
$requete_note = "SELECT note FROM Avis WHERE Avis.mail = $mail";
$result_commentaire = pg_query_params($db, $requete_commentaire);
$resulttab_commentaire = pg_fetch_array($result_commentaire);
$result_dateAvis = pg_query_params($db, $requete_dateAvis);
$resulttab_dateAvis = pg_fetch_array($result_dateAvis);
$result_note = pg_query_params($db, $requete_note);
$resulttab_note = pg_fetch_array($result_note);
?> ?>
@ -42,45 +32,39 @@ $resulttab_note = pg_fetch_array($result_note);
<div id = "container"> <div id = "container">
<div id ="entete"> <div id ="entete">
<a href = "https://stri.flavien.ovh/tableauBord/tableauBord.php"><img id = "bouton_retour" src = "../resources/return.png" alt = "Bouton retour"></a> <a href = "https://stri.flavien.ovh/tableauBord/tableauBord.php"><img id = "bouton_retour" src = "../ressources/image/return.png" alt = "Bouton retour"></a>
<h1 id = "titre">Avis Laissés</h1> <h1 id = "titre">Avis Laissés</h1>
<br> <br>
</div> </div>
<div id = "avis"> <div id = "avis">
<table> <table>
<tr> <?php
<td id="avis_tab"> while ($row = pg_fetch_array($result)) {
<?PHP $nom = $row['login'];
$date = $row['dateavis'];
$commentaire = $row['commentaire'];
$note = $row['note'];
echo "<tr>";
echo "<td class='avis_tab'>";
echo "<h3 id='nom'>$nom</h3>";
echo "<h4 id='date'>".explode(' ',$date)[0]."</h4>";
echo "<h5 id='avis'>$commentaire</h5>";
echo "</td>";
echo "<td id='note_tab'>";
$i=0; $i=0;
while (strlen($resulttab_commentaire)>$i){ while ($i<intval($note)){
echo "<h3 id=\"nom\"> $login </h3>" echo "<img class='etoile' src='../ressources/image/star_full.png' alt='star'>";
echo "<h4 id=\"date\"> $resulttab_dateAvis[$i] </h4>"
echo "<h5 id=\"avis\"> $resulttab_dateAvis[$i] </h5>"
$i++; $i++;
} }
?> $i = $note;
</td> while ($i<3){
<td id="note_tab"> echo "<img class='etoile' src='../ressources/image/star.png' alt='star'>";
<?php
$j=0;
while (strlen($resulttab_note)>$j){
if ($resulttab_note[$j]==0){
echo "<img class=\"etoile\" src=\"../resources/star.png\" alt=\"star\"><img class=\"etoile\" src=\"../resources/star.png\" alt=\"star\"><img class=\"etoile\" src=\"../resources/star.png\" alt=\"star\">";
}
else if ($resulttab_note[$j]==1) {
echo "<img class=\"etoile\" src=\"../resources/star_full.png\" alt=\"star\"><img class=\"etoile\" src=\"../resources/star.png\" alt=\"star\"><img class=\"etoile\" src=\"../resources/star.png\" alt=\"star\">";
}
else if ($resulttab_note[$j]==2) {
echo "<img class=\"etoile\" src=\"../resources/star_full.png\" alt=\"star\"><img class=\"etoile\" src=\"../resources/star_full.png\" alt=\"star\"><img class=\"etoile\" src=\"../resources/star.png\" alt=\"star\">";
}
else {
echo "<img class=\"etoile\" src=\"../resources/star_full.png\" alt=\"star\"><img class=\"etoile\" src=\"../resources/star_full.png\" alt=\"star\"><img class=\"etoile\" src=\"../resources/star_full.png\" alt=\"star\">";
}
$i++; $i++;
} }
echo "</td>";
}
?> ?>
</td>
</tr> </tr>
</table> </table>
</div> </div>

@ -7,7 +7,7 @@ Page CSS : avis_recu.css
body { body {
color:black; color:black;
background-color:white; background-color:white;
background-image:url(../resources/background.jpg); background-image:url("../ressources/image/background.jpg");
background-repeat:no-repeat; background-repeat:no-repeat;
background-size:104%; background-size:104%;
margin: 0; margin: 0;
@ -40,7 +40,7 @@ h2{
height:50px; height:50px;
} }
#avis_tab{ .avis_tab{
width:85%; width:85%;
padding-left:15%; padding-left:15%;
} }

@ -1,7 +1,7 @@
<?php <?php
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'])) {
@ -12,68 +12,55 @@ $mail = $_SESSION['mail'];
$login = getLogin($db, $mail); $login = getLogin($db, $mail);
$requete_commentaire = "SELECT commentaire FROM Avis WHERE Avis.mail != $mail"; $requete = "SELECT DISTINCT Utilisateur.login, Avis.commentaire, Avis.dateavis, Avis.note FROM Utilisateur, Avis, Trajet WHERE Avis.codetrajet = Trajet.codetrajet AND Trajet.mailproposition = $1 AND Trajet.mailproposition = Utilisateur.mail;";
$requete_dateAvis = "SELECT dateAvis FROM Avis WHERE Avis.mail != $mail"; $result = pg_query_params($db, $requete, array($mail));
$requete_note = "SELECT note FROM Avis WHERE Avis.mail != $mail";
$requete_login = "SELECT login FROM Avis WHERE Avis.mail != $mail";
$result_commentaire = pg_query_params($db, $requete_commentaire);
$resulttab_commentaire = pg_fetch_array($result_commentaire);
$result_dateAvis = pg_query_params($db, $requete_dateAvis);
$resulttab_dateAvis = pg_fetch_array($result_dateAvis);
$result_note = pg_query_params($db, $requete_note);
$resulttab_note = pg_fetch_array($result_note);
$result_login = pg_query_params($db, $requete_login);
$resulttab_login = pg_fetch_array($result_login);
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel="stylesheet" href="avis_recus.css"> <link rel="stylesheet" href="avis_recus.css">
<link rel="stylesheet" href="../ressources/navbarhtml.css">
<link rel="icon" href="../ressources/favicon.ico"/> <link rel="icon" href="../ressources/favicon.ico"/>
<title>Avis Recus</title> <title>Avis Recus</title>
</head> </head>
<body> <body>
<?php require_once ("../ressources/navbarhtml.php"); ?>
<div id="container"> <div id="container">
<div id="entete"> <div id="entete">
<a href = "https://stri.flavien.ovh/tableauBord/tableauBord.php"><img id = "bouton_retour" src = "../resources/return.png" alt = "Bouton retour"></a> <a href="../tableauBord/tableauBord.php"><img id="bouton_retour"
src="../ressources/image/return.png"
alt="Bouton retour"></a>
<h1 id="titre">Avis Recus</h1> <h1 id="titre">Avis Recus</h1>
<br> <br>
</div> </div>
<div id="avis"> <div id="avis">
<table> <table>
<tr> <?php while ($row = pg_fetch_array($result)) {
<td id="avis_tab"> $nom = $row['login'];
<?php $date = $row['dateavis'];
$commentaire = $row['commentaire'];
$note = $row['note'];
echo "<tr>";
echo "<td class='avis_tab'>";
echo "<h3 id='nom'>$nom</h3>";
echo "<h4 id='date'>".explode(' ',$date)[0]."</h4>";
echo "<h5 id='avis'>$commentaire</h5>";
echo "</td>";
echo "<td id='note_tab'>";
$i=0; $i=0;
while (strlen($resulttab_commentaire)>$i){ while ($i<intval($note)){
echo "<h3 id=\"nom\"> $resulttab_login[$i]</h3>" echo "<img class='etoile' src='../ressources/image/star_full.png' alt='star'>";
echo "<h4 id=\"date\"> $resulttab_dateAvis[$i] </h4>"
echo "<h5 id=\"avis\"> $resulttab_dateAvis[$i] </h5>"
$i++; $i++;
} }
?> $i = $note;
</td> while ($i<3){
<td id="note_tab"> echo "<img class='etoile' src='../ressources/image/star.png' alt='star'>";
<?php $i++;
if ($note==0){
echo "<img class=\"etoile\" src=\"../resources/star.png\" alt=\"star\"><img class=\"etoile\" src=\"../resources/star.png\" alt=\"star\"><img class=\"etoile\" src=\"../resources/star.png\" alt=\"star\">";
}
elseif ($note==1){
echo "<img class=\"etoile\" src=\"../resources/star_full.png\" alt=\"star\"><img class=\"etoile\" src=\"../resources/star.png\" alt=\"star\"><img class=\"etoile\" src=\"../resources/star.png\" alt=\"star\">";
}
elseif ($note==2){
echo "<img class=\"etoile\" src=\"../resources/star_full.png\" alt=\"star\"><img class=\"etoile\" src=\"../resources/star_full.png\" alt=\"star\"><img class=\"etoile\" src=\"../resources/star.png\" alt=\"star\">";
} }
else { echo "</td>";
echo "<img class=\"etoile\" src=\"../resources/star_full.png\" alt=\"star\"><img class=\"etoile\" src=\"../resources/star_full.png\" alt=\"star\"><img class=\"etoile\" src=\"../resources/star_full.png\" alt=\"star\">";
} }
?> ?>
</td>
</tr> </tr>
</table> </table>
</div> </div>

@ -5,11 +5,11 @@
} }
body{ body{
background-image:url("../ressources/image/background.jpg");
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
flex-direction: row; flex-direction: row;
justify-content: center; justify-content: center;
align-items: center;
} }
h1{ h1{
@ -52,6 +52,7 @@ h1{
} }
#formulaire{ #formulaire{
margin-top: ;
background-color: white; background-color: white;
border-radius: 10px; border-radius: 10px;
padding: 4em; padding: 4em;

@ -1,4 +1,5 @@
<?php <?php
session_start();
require_once('../connexionBD.php'); require_once('../connexionBD.php');
require_once('../ressources/trajet.php'); require_once('../ressources/trajet.php');
require_once ('../ressources/verifconnecte.php'); require_once ('../ressources/verifconnecte.php');
@ -100,7 +101,11 @@ if (isset($_POST['dateDepart']) && isset($_POST['dateArrivee']) && isset($_POST[
<input id="supprimerEtape" class='button' type='button' value='Supprimer une étape'> <input id="supprimerEtape" class='button' type='button' value='Supprimer une étape'>
<input id="nbEtapes" name="nbEtapes" type="hidden" value="1" required> <input id="nbEtapes" name="nbEtapes" type="hidden" value="1" required>
</div> </div>
<?php getErrorDepotTrajet($_GET['error']); ?> <?php
if (isset($_GET['error'])){
getErrorDepotTrajet($_GET['error']);
}
?>
<div class="line"> <div class="line">
<input id="submit" class="button" type="submit" value="Poster le trajet"> <input id="submit" class="button" type="submit" value="Poster le trajet">
</div> </div>

@ -1,14 +1,7 @@
/*
Crée par PALAFFRE Raphael
Fonction:Depot d'avis
Page PHP : deposer_avis.php
Page HTML : deposer_avis.html
*/
body { body {
color:black; color:black;
background-color:white; background-color:white;
background-image:url(../resources/background.jpg); background-image:url("../ressources/image/background.jpg");
background-repeat:no-repeat; background-repeat:no-repeat;
background-size:104%; background-size:104%;
margin: 0; margin: 0;
@ -32,7 +25,10 @@ h1{
} }
#avis_laisse{ #avis_laisse{
resize: none box-sizing: border-box;
resize: none;
width: 70%;
height: 16em;
} }
#submit{ #submit{

@ -1,7 +1,22 @@
<?php <?php
function checkAvis($db, $mail, $codetrajet)
{
$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 avis av, trajet tr, reserver re WHERE av.codetrajet = $2 AND av.codetrajet = tr.codetrajet AND tr.codetrajet = re.codetrajet AND re.mailutilisateur = $1;", array($mail, $codetrajet));
$row = pg_fetch_array($result);
return $row[0] >= 1;
}
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'])) {
@ -11,63 +26,59 @@ if (!isset($_SESSION['mail'])) {
$mail = $_SESSION['mail']; $mail = $_SESSION['mail'];
if (isset($_GET['codeTrajet'])) { if (isset($_POST['codetrajet']) && isset($_POST['avislaisse']) && isset($_POST['note'])) {
$mail = $_SESSION['mail']; $avis = $_POST['avislaisse'];
$avis = $_POST['avis_laisse'];
$note = $_POST['note']; $note = $_POST['note'];
$date = date("Y-m-d H:i:s"); $codetrajet = intval($_POST['codetrajet']);
$estLu = 0; $date = date('Y-m-d H:i:s');
$codeTrajet = $_GET['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 ($mail,$codeTrajet,$avis,$date,$note,$estLu);"; $envoi = pg_query_params($db, $requete, array($mail, $codetrajet, $avis, $date, $note));
if (!$envoi) {
$envoi = pg_query($db,$requete); echo "Erreur d'ecriture dans la BD";
exit();
if ($envoi == FALSE){ } else {
echo 'Erreur d\'ecriture dans la BD'; header('Location: ../index.php');
exit();
} }
} }
else{
echo 'Erreur codeTrajet';
} }
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fr"> <html lang="fr">
<head> <head>
<!--
Crée par PALAFFRE Raphael
Fonction:Depot d'avis
Page PHP : deposer_avis.php
Page CSS : deposer_avis.css
-->
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel="stylesheet" href="deposer_avis.css"> <link rel="stylesheet" href="deposer_avis.css">
<link rel="stylesheet" href="../ressources/navbarhtml.css">
<link rel="icon" href="../ressources/favicon.ico"/> <link rel="icon" href="../ressources/favicon.ico"/>
<title>Deposer un avis</title> <title>Deposer un avis</title>
</head> </head>
<body> <body>
<?php require_once("../ressources/navbarhtml.php"); ?>
<div id="container"> <div id="container">
<div id="entete"> <div id="entete">
<h1 id="titre">Deposer un avis</h1> <h1 id="titre">Deposer un avis</h1>
</div> </div>
<div id="form"> <div id="form">
<form id="formulaire_avis" action="deposer_avis.php" method="post"> <form id="formulaire_avis" enctype="multipart/form-data" action="deposer_avis.php" method="post">
<div> <textarea id="avis_laisse" name="avislaisse" form="formulaire_avis" placeholder="Avis"></textarea>
<textarea id="avis_laisse" name="avis_laisse" form="formulaire_avis" rows="10" cols="100" placeholder="Avis"></textarea>
</div>
<h2>NOTE</h2> <h2>NOTE</h2>
<div class="rating"> <div class="rating">
<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">
<a href="#2" label for="note2" title="Donner 2 étoiles"></a> <a href="#2" label for="note2" title="Donner 2 étoiles"></a>
<input type="radio" name="note" id="note1" value="1"/> <input type="radio" name="note" id="note1" value="1">
<a href="#1" label for="note1" title="Donner 1 étoiles"></a> <a href="#1" label for="note1" title="Donner 1 étoiles"></a>
<?php
if (isset($_GET['codetrajet'])) {
$codeTrajet = $_GET['codetrajet'];
echo "<input type='hidden' name='codetrajet' value='$codeTrajet'>";
}
?>
</div> </div>
<br> <br>
<div>
<input type="submit" value="Valider" id="submit"> <input type="submit" value="Valider" id="submit">
</div>
</form> </form>
</div> </div>
</div> </div>

@ -0,0 +1,54 @@
/*
Crée par PALAFFRE Raphael
Fonction: Lister les trajets recherché
Page PHP : liste.php
*/
body {
color:black;
background-color:white;
background-image:url(../resources/background.jpg);
background-repeat:no-repeat;
background-size:104%;
margin: 0;
font-family: Ubuntu,Helvetica,sans-serif;
}
#container{
margin : 5% 5% 5% 5%;
background-color : white;
border : 2px solid black;
}
h1{
text-align : center;
font-size : 250%;
font-weight: bold;
}
h2{
text-align : center;
font-size : 150%;
font-weight: bold;
}
#bouton_retour{
transform : rotate(45deg);
}
.separation{
margin-top : 5%;
margin-left : 20%;
height: 200px;
width : 5px;
background: black;
}
#ligne{
padding-left:10%;
width: 33%;
}
#info{
width: 60%;
}

@ -0,0 +1,49 @@
<?php
session_start();
require_once("../connexionBD.php");
require_once ("../ressources/trajet.php");
//Si on est pas connecté redirection vers la page de connexion
if (!isset($_SESSION['mail'])) {
header('Location: ../index.php');
exit();
}
$mail = $_SESSION['mail'];
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="liste_trajet_reserve.css">
<link rel="icon" href="../ressources/favicon.ico"/>
<title>Liste des trajets</title>
</head>
<body>
<div id="container">
<div id="entete">
<a href="../tableauBord/tableauBord.php"><img id="bouton_retour" src="../resources/return.png"
alt="Bouton retour"></a>
<h1 class="float" id="titre">Liste des trajets réservés</h1>
<br>
</div>
<div id="liste">
<table>
<?php
$result = pg_query_params($db, "SELECT DISTINCT ut.login as login, tr.* FROM utilisateur ut, trajet tr, reserver re WHERE ut.mail = re.mailutilisateur AND re.codetrajet = tr.codetrajet AND re.mailutilisateur = $1 AND tr.estannule;", array($mail));
while ($row = pg_fetch_array($result)) {
$login = $row['login'];
$date_depart = $row['datedepart'];
$codetrajet = $row['codetrajet'];
$source = getDepart($db, $codetrajet);
$dest = getFin($db, $codetrajet);
echo "<tr><td class='ligne'><hr class='separation'/></td><td class='info'>";
echo "<p>$date_depart - $source --> $dest : $login</p></td>";
echo "</tr>";
}
?>
</table>
</div>
</div>
</body>
</html>

@ -1,6 +1,6 @@
<?php <?php
session_start(); session_start();
require_once (../connexionBD.php); require_once ("../connexionBD.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'])) {
@ -59,8 +59,8 @@ if ($envoi == FALSE){
<td id="reserver"> <td id="reserver">
<form action="contact.php" method="POST"> <form action="contact.php" method="POST">
<?php <?php
echo "<input type=\"hidden\" name=\"login\" value=\"$login\"/>"; echo "<input type='hidden' name='login' value='$login'/>";
echo "<input type=\"hidden\" name=\"codeTrajet\" value=\"$codeTrajet\"/>"; echo "<input type='hidden' name='codeTrajet' value='$codeTrajet'/>";
?> ?>
<input type="submit" value="Reserver"> <input type="submit" value="Reserver">
</form> </form>

@ -28,3 +28,116 @@
#changePass{ #changePass{
margin-bottom: 0.7em; margin-bottom: 0.7em;
} }
*{
margin: 0;
padding: 0;
font-family: "Arial";
font-size: 1em;
}
html, body{
height: 100%;
}
body{
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: center;
background-image: url("../ressources/image/background.jpg");
background-size : cover;
background-position: center, center;
}
#formulaire{
background-color: white;
border-radius: 10px;
padding: 4em;
width: 40%;
}
#enregistrer{
margin-top: 1em;
text-align: center;
}
h1{
text-align: center;
}
form{
margin-top: 3em;
}
.form{
box-sizing: border-box;
width: 55%;
border: 1px solid grey;
margin-bottom: 0.7em;
}
#avatar{
border-style: none;
}
.button{
cursor: pointer;
font-weight: bold;
padding: 8px;
color: white;
background-color: rgb(65, 154, 28);
border-radius: 5em;
border: none;
}
.button:hover{
background-color: rgb(48, 112, 20);
border-color: rgb(48, 112, 20);
}
.button:disabled{
cursor: not-allowed;
background-color: grey;
}
#submit{
margin-top: 1em;
margin-left: 50%;
transform: translate(-50%);
}
.line{
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: left;
width: 100%;
}
#error{
margin-bottom: 1em;
}
.error{
color: red;
text-align: center;
}
label{
box-sizing: border-box;
font-size: 1.1em;
width: 45%;
min-width: 8em;
}
h1{
font-size: 2em;
}
button{
color: forestgreen;
border-color: forestgreen;
border-radius: 5em;
}

@ -4,7 +4,6 @@ require_once('../connexionBD.php');
require_once ('../ressources/user.php'); require_once ('../ressources/user.php');
require_once ('../ressources/voiture.php'); require_once ('../ressources/voiture.php');
$mail = $_SESSION['mail'];
$matricule = isset($_POST['matricule']) ? $_POST['matricule'] : NULL; //recuperation valeur formulaire, isset pour eviter l'erreur "Notice: Undefined index" $matricule = isset($_POST['matricule']) ? $_POST['matricule'] : NULL; //recuperation valeur formulaire, isset pour eviter l'erreur "Notice: Undefined index"
$marque = isset($_POST['marque']) ? $_POST['marque'] : NULL; $marque = isset($_POST['marque']) ? $_POST['marque'] : NULL;
$modele = isset($_POST['modele']) ? $_POST['modele'] : NULL; $modele = isset($_POST['modele']) ? $_POST['modele'] : NULL;
@ -15,10 +14,15 @@ if (!isset($_SESSION['mail'])) {
header('Location: index.php'); header('Location: index.php');
exit(); exit();
} }
$mail = $_SESSION['mail'];
if (isset($_POST['submitadd'])) { if (isset($_POST['submitadd'])) {
$result = pg_query_params($db, "SELECT COUNT(*), matricule FROM voiture WHERE mail = $1 GROUP BY matricule;", array($mail));
$row = pg_fetch_array($result);
if($row[0] == 0){
addVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab); addVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab);
} }
}
if (isset($_POST['submitchange'])) { if (isset($_POST['submitchange'])) {
changeVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab); changeVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab);
} }
@ -88,7 +92,6 @@ if (isset($_POST['login']) || isset($_FILES['avatar'])){
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel="stylesheet" href="profil.css"> <link rel="stylesheet" href="profil.css">
<link rel="stylesheet" href="../ressources/navbarhtml.css"> <link rel="stylesheet" href="../ressources/navbarhtml.css">
<link rel="stylesheet" href="../index.css">
<script src="../inscription/inscription.js"></script> <script src="../inscription/inscription.js"></script>
<title>Profil</title> <title>Profil</title>
</head> </head>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 1.9 MiB

@ -1,18 +1,12 @@
<?php
$path = "..";
if (file_exists("./inscription.php")) {
$path = ".";
}
?>
<div id="menuDiv"> <div id="menuDiv">
<nav id="menu"> <nav id="menu">
<div id="divFlex"><div id="divlogo"><img src="../ressources/logo.png" alt="logo Upssi'Covoit" id="logo"/></div></div> <div id="divFlex"><div id="divlogo"><img src="../ressources/logo.png" alt="logo Upssi'Covoit" id="logo"/></div></div>
<a class="menuItem" href="<?php echo $path ; ?>../tableauBord/tableauBord.php">Tableau de bord</a> <a class="menuItem" href="../tableauBord/tableauBord.php">Tableau de bord</a>
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Trajets publiés</a> <a class="menuItem" href="/inscription.php">Trajets publiés</a>
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Trajets réservés</a> <a class="menuItem" href="../listeTrajetReserve/liste_trajet_reserve.php">Trajets réservés</a>
<a class="menuItem" href="<?php echo $path ; ?>../avis_recus/avis_recus.php">Avis reçus</a> <a class="menuItem" href="../avis_recus/avis_recus.php">Avis reçus</a>
<a class="menuItem" href="<?php echo $path ; ?>../avis_laisses/avis_laisses.php">Avis laissés</a> <a class="menuItem" href="../avis_laisses/avis_laisses.php">Avis laissés</a>
<a class="menuItem" href="<?php echo $path ; ?>../profil/profil.php">Profil</a> <a class="menuItem" href="../profil/profil.php">Profil</a>
<a class="menuItem" href="<?php echo $path ; ?>../deconnexion.php">Se déconnecter</a> <a class="menuItem" href="../deconnexion.php">Se déconnecter</a>
</nav> </nav>
</div> </div>

@ -100,6 +100,24 @@ function afficherVilles($db){
} }
} }
function getDepart($db, $codetajet){
$result = pg_query_params($db, "SELECT v.nomVille FROM ville v, traverser tr WHERE tr.nomVille = v.nomVille AND tr.codepostal = v.codepostal AND tr.codetrajet = $1 AND tr.numeroetape = (SELECT MIN(numeroetape) FROM traverser WHERE codetrajet = $1);", array($codetajet));
$return = false;
if ($result){
$return = pg_fetch_array($result)[0];
}
return $return;
}
function getFin($db, $codetajet){
$result = pg_query_params($db,"SELECT v.nomVille FROM ville v, traverser tr WHERE tr.nomVille = v.nomVille AND tr.codepostal = v.codepostal AND tr.codetrajet = $1 AND tr.numeroetape = (SELECT MAX(numeroetape) FROM traverser WHERE codetrajet = $1);", array($codetajet));
$return = false;
if ($result){
$return = pg_fetch_array($result)[0];
}
return $return;
}
function getErrorDepotTrajet($code){ function getErrorDepotTrajet($code){
switch ($code) { switch ($code) {
case 1: case 1:

@ -1,13 +1,15 @@
<?php <?php
//geterror de l'index //geterror de l'index
function getErrorIndex($code){ function getErrorIndex($code)
{
switch ($code) { switch ($code) {
case 1: case 1:
return "Adresse mail ou mot de passe invalide."; return "Adresse mail ou mot de passe invalide.";
} }
} }
function getErrorProfil($code){ function getErrorProfil($code)
{
switch ($code) { switch ($code) {
case 1: case 1:
return "Ce login est déjà associé à un compte."; return "Ce login est déjà associé à un compte.";
@ -24,7 +26,8 @@ function getErrorProfil($code){
} }
} }
function getErrorInscription($code){ function getErrorInscription($code)
{
switch ($code) { switch ($code) {
case 1: case 1:
return "L'adresse mail est invalide."; return "L'adresse mail est invalide.";
@ -41,7 +44,8 @@ function getErrorInscription($code){
} }
} }
function authentification($db, $mail, $password){ function authentification($db, $mail, $password)
{
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail)); $result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail));
if ($result) { if ($result) {
$row = pg_fetch_array($result); $row = pg_fetch_array($result);
@ -50,11 +54,13 @@ function authentification($db, $mail, $password){
return false; return false;
} }
function loginChange($user, $login){ function loginChange($user, $login)
{
return strcmp($user['login'], $login); return strcmp($user['login'], $login);
} }
function isLoginUniqueModifier($db, $mail, $login){ function isLoginUniqueModifier($db, $mail, $login)
{
$result = pg_query_params($db, "SELECT login FROM Utilisateur WHERE login = $1 AND mail != $2;", array($login, $mail)); $result = pg_query_params($db, "SELECT login FROM Utilisateur WHERE login = $1 AND mail != $2;", array($login, $mail));
if ($result) { if ($result) {
$row = pg_fetch_array($result); $row = pg_fetch_array($result);
@ -63,22 +69,26 @@ function isLoginUniqueModifier($db, $mail, $login){
return false; return false;
} }
function modifierLogin($db, $mail, $login){ function modifierLogin($db, $mail, $login)
{
$result = pg_query_params($db, "UPDATE Utilisateur SET login = $1 WHERE mail = $2;", array($login, $mail)); $result = pg_query_params($db, "UPDATE Utilisateur SET login = $1 WHERE mail = $2;", array($login, $mail));
return $result; return $result;
} }
function modifierUtilisateur($db, $mail, $prenom, $nom, $password, $phone){ function modifierUtilisateur($db, $mail, $prenom, $nom, $password, $phone)
{
$result = pg_query_params($db, "UPDATE Utilisateur SET prenom = $1, nom = $2, telephone = $3 , passwd = $4 WHERE mail = $5;", array($prenom, $nom, $phone, $password, $mail)); $result = pg_query_params($db, "UPDATE Utilisateur SET prenom = $1, nom = $2, telephone = $3 , passwd = $4 WHERE mail = $5;", array($prenom, $nom, $phone, $password, $mail));
return $result; return $result;
} }
function getUser($db, $mail){ function getUser($db, $mail)
{
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail)); $result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail));
return pg_fetch_array($result); return pg_fetch_array($result);
} }
function getPrenom($db, $mail){ function getPrenom($db, $mail)
{
$result = pg_query_params($db, "SELECT prenom from Utilisateur WHERE mail = $1;", array($mail)); $result = pg_query_params($db, "SELECT prenom from Utilisateur WHERE mail = $1;", array($mail));
if ($result) { if ($result) {
$row = pg_fetch_array($result); $row = pg_fetch_array($result);
@ -88,7 +98,8 @@ function getPrenom($db, $mail){
return false; return false;
} }
function getLogin($db, $mail){ function getLogin($db, $mail)
{
$result = pg_query_params($db, "SELECT login from Utilisateur WHERE mail = $1;", array($mail)); $result = pg_query_params($db, "SELECT login from Utilisateur WHERE mail = $1;", array($mail));
if ($result) { if ($result) {
$row = pg_fetch_array($result); $row = pg_fetch_array($result);
@ -98,7 +109,8 @@ function getLogin($db, $mail){
return false; return false;
} }
function getPathImgProfilTableau($mail){ function getPathImgProfilTableau($mail)
{
$list = scandir("../imageProfil"); $list = scandir("../imageProfil");
foreach ($list as $entry) { foreach ($list as $entry) {
if (strpos($entry, $mail) !== false) { if (strpos($entry, $mail) !== false) {
@ -108,7 +120,8 @@ function getPathImgProfilTableau($mail){
return "../imageProfil/default.svg"; return "../imageProfil/default.svg";
} }
function getPathImgProfil($mail){ function getPathImgProfil($mail)
{
$list = scandir("../imageProfil"); $list = scandir("../imageProfil");
foreach ($list as $entry) { foreach ($list as $entry) {
if (strpos($entry, $mail) !== false) { if (strpos($entry, $mail) !== false) {
@ -118,7 +131,8 @@ function getPathImgProfil($mail){
return "../imageProfil/default.svg"; return "../imageProfil/default.svg";
} }
function supprimerAvatar($mail){ function supprimerAvatar($mail)
{
$list = scandir("../imageProfil"); $list = scandir("../imageProfil");
foreach ($list as $entry) { foreach ($list as $entry) {
if (strpos($entry, $mail) !== false) { if (strpos($entry, $mail) !== false) {
@ -127,7 +141,8 @@ function supprimerAvatar($mail){
} }
} }
function isMailUnique($db, $mail){ function isMailUnique($db, $mail)
{
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail)); $result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail));
if ($result) { if ($result) {
$row = pg_fetch_array($result); $row = pg_fetch_array($result);
@ -136,7 +151,8 @@ function isMailUnique($db, $mail){
return false; return false;
} }
function isLoginUnique($db, $login){ function isLoginUnique($db, $login)
{
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE login = $1;", array($login)); $result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE login = $1;", array($login));
if ($result) { if ($result) {
$row = pg_fetch_array($result); $row = pg_fetch_array($result);
@ -145,12 +161,14 @@ function isLoginUnique($db, $login){
return false; return false;
} }
function creerUtilisateur($db, $mail, $password, $prenom, $nom, $login, $phone, $dateN){ function creerUtilisateur($db, $mail, $password, $prenom, $nom, $login, $phone, $dateN)
{
$result = pg_query_params($db, "INSERT INTO Utilisateur VALUES ($1, $2, $3, $4, $5, $6, to_date($7, 'YYYY/MM/DD'), false);", array($mail, $password, $prenom, $nom, $login, $phone, $dateN)); $result = pg_query_params($db, "INSERT INTO Utilisateur VALUES ($1, $2, $3, $4, $5, $6, to_date($7, 'YYYY/MM/DD'), false);", array($mail, $password, $prenom, $nom, $login, $phone, $dateN));
return $result; return $result;
} }
function uploadAvatar($mail, $fic){ function uploadAvatar($mail, $fic)
{
$tmp = explode('.', $fic['name']); $tmp = explode('.', $fic['name']);
$extension = end($tmp); $extension = end($tmp);
$target_file = "../imageProfil/$mail.$extension"; $target_file = "../imageProfil/$mail.$extension";
@ -168,7 +186,8 @@ function uploadAvatar($mail, $fic){
return 0; return 0;
} }
function deluser($delmail){ function deluser($db, $delmail)
{
/* /*
$requete = "UPDATE public.utilisateur SET (mail, passwd, prenom, nom, login, telephone, datenaissance, estadmin) = ('utilisateur_supprime@local', '', '', '', 'utilisateur_supprime', '', to_date('1970/01/01','YYYY/MM/DD'), false) WHERE mail = '".$delmail."';"; $requete = "UPDATE public.utilisateur SET (mail, passwd, prenom, nom, login, telephone, datenaissance, estadmin) = ('utilisateur_supprime@local', '', '', '', 'utilisateur_supprime', '', to_date('1970/01/01','YYYY/MM/DD'), false) WHERE mail = '".$delmail."';";
marche pas marche pas
@ -179,12 +198,17 @@ function deluser($delmail){
/* /*
a faire = array('' => , );Delete l'utilisateur du reste de la base a faire = array('' => , );Delete l'utilisateur du reste de la base
*/ */
$requete = "UPDATE trajet SET mailproposition = 'utilisateur_supprime@local' WHERE mailproposition = $delmail;";
pg_query($db, $requete);
$requete = "UPDATE reserver SET mailutilisateur = 'utilisateur_supprime@local' WHERE mailutilisateur = $delmail;";
pg_query($db, $requete);
$requete = "DELETE FROM avis WHERE mailemetteur = $delmail;";
pg_query($db, $requete);
$requete = "DELETE FROM voiture WHERE mail = $delmail;";
pg_query($db, $requete);
$requete = "DELETE FROM utilisateur WHERE mail = $delmail;";
pg_query($db, $requete);
$requete = "DELETE FROM public.utilisateur WHERE mail = '".$delmail."';";
if(pg_query($db, $requete)){
supprimerAvatar($delmail);
echo "c'est supprimé";
}
} }
?> ?>

@ -23,7 +23,7 @@ require_once ('../ressources/verifconnecte.php');
<img id="imgProfil" src="<?php echo getPathImgProfilTableau($mail); ?>"> <img id="imgProfil" src="<?php echo getPathImgProfilTableau($mail); ?>">
</div> </div>
<div id="trajet"> <div id="trajet">
<a class="btnTrajet" href="../ah.php">Déposer un trajet</a> <a class="btnTrajet" href="../deposerTrajet/depotTrajet.php">Déposer un trajet</a>
<a id="btnTrajet2" class="btnTrajet" href="../ah.php">Rechercher un trajet</a> <a id="btnTrajet2" class="btnTrajet" href="../ah.php">Rechercher un trajet</a>
</div> </div>
<div id="recap"> <div id="recap">

Loading…
Cancel
Save