Merge branch 'profil'
This commit is contained in:
commit
c63d1b76db
170
WEB/profil.php
170
WEB/profil.php
@ -1,170 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once('connexionBD.php');
|
||||
require_once ('ressources/user.php');
|
||||
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['mail'])) {
|
||||
header('Location: index.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
$mail = $_SESSION['mail'];
|
||||
|
||||
$user = getUser($db, $mail);
|
||||
|
||||
if (!$user) {
|
||||
header('Location: profil.php?error=3');
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_POST['login']) || isset($_FILES['avatar'])){
|
||||
if (isset($_FILES['avatar']) and !empty($_FILES['avatar']['name'])) {
|
||||
$fic = $_FILES['avatar'];
|
||||
supprimerAvatar($mail);
|
||||
$res = uploadAvatar($mail, $fic);
|
||||
switch ($res){
|
||||
case -1:
|
||||
header('Location: profil.php?error=4');
|
||||
exit();
|
||||
case -2:
|
||||
header('Location: profil.php?error=5');
|
||||
exit();
|
||||
case -3:
|
||||
header('Location: profil.php?error=6');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
if (isset($_POST['login']) && isset($_POST['password']) && isset($_POST['confirmation']) && isset($_POST['prenom']) && isset($_POST['nom']) && isset($_POST['phone'])) {
|
||||
$login = htmlentities(pg_escape_string($_POST['login']));
|
||||
$password = htmlentities(pg_escape_string($_POST['password']));
|
||||
$confirmation = htmlentities(pg_escape_string($_POST['confirmation']));
|
||||
$prenom = htmlentities(pg_escape_string($_POST['prenom']));
|
||||
$nom = htmlentities(pg_escape_string($_POST['nom']));
|
||||
$phone = htmlentities(pg_escape_string($_POST['phone']));
|
||||
|
||||
if (loginChange($user, $login)) {
|
||||
if (!isLoginUniqueModifier($db, $mail, $login)) {
|
||||
header('Location: profil.php?error=1');
|
||||
exit();
|
||||
} else {
|
||||
if (!modifierLogin($db, $mail, $login)) {
|
||||
header('Location: profil.php?error=6');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp($password, $confirmation) != 0) {
|
||||
header('Location: profil.php?error=2');
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!modifierUtilisateur($db, $mail, $prenom, $nom, $password, $phone)) {
|
||||
header('Location: profil.php?error=6');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
sleep(0.85);
|
||||
header('Location: profil.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
function printError()
|
||||
{
|
||||
if (isset($_GET['error'])) {
|
||||
$erreur = getErrorProfil($_GET['error']);
|
||||
echo "<p class = 'error'>$erreur</p>";
|
||||
}
|
||||
}
|
||||
|
||||
function getErrorProfil($code)
|
||||
{
|
||||
switch ($code) {
|
||||
case 1:
|
||||
return "Ce login est déjà associé à un compte.";
|
||||
case 2:
|
||||
return "Les mots de passe ne correspondent pas.";
|
||||
case 3:
|
||||
return "Erreur lors de la récupération des informations de profil.";
|
||||
case 4:
|
||||
return "Le fichier envoyé doit être une image au format PNG ou JPEG.";
|
||||
case 5:
|
||||
return "La taille de l'image ne doit pas dépasser 2 MB.";
|
||||
case 6:
|
||||
return "Erreur lors de la modification du compte.";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="profil.css">
|
||||
<link rel="stylesheet" href="ressources/navbarhtml.css">
|
||||
<link rel="stylesheet" href="index_inscription.css">
|
||||
<script src="inscription.js"></script>
|
||||
<title>Profil</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php require_once("ressources/navbarhtml.php"); ?>
|
||||
<div id="formulaire">
|
||||
<h1>Profil</h1>
|
||||
<div id="divImgProfil">
|
||||
<img id="imgProfil" src="<?php echo getPathImgProfil($mail); ?>">
|
||||
</div>
|
||||
<form method="post" action="profil.php" enctype="multipart/form-data">
|
||||
<div class="line">
|
||||
<label for="mail">Adresse mail : </label>
|
||||
<input id="mail" class="form" type="email" maxlength="100" readonly value="<?php echo $user['mail']; ?>">
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="login">Login : </label>
|
||||
<input id="login" class="form" name="login" type="text" maxlength="50"
|
||||
value="<?php echo $user['login']; ?>" required>
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="password">Mot de passe : </label>
|
||||
<input class="form" id="password" name="password" type="password" maxlength="50"
|
||||
value="<?php echo $user['passwd']; ?>" required>
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="confirmation">Confirmation : </label>
|
||||
<input class="form" id="confirmation" name="confirmation" type="password" maxlength="16"
|
||||
value="<?php echo $user['passwd']; ?>" required>
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="prenom">Prénom : </label>
|
||||
<input id="prenom" class="form" name="prenom" type="text" maxlength="50"
|
||||
value="<?php echo $user['prenom']; ?>" required>
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="nom">Nom : </label>
|
||||
<input id="nom" class="form" name="nom" type="text" maxlength="50" value="<?php echo $user['nom']; ?>"
|
||||
required>
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="dateN">Date de naissance : </label>
|
||||
<input id="dateN" class="form" readonly="readonly" type="date"
|
||||
value="<?php echo $user['datenaissance']; ?>" required>
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="phone">Numéro de téléphone : </label>
|
||||
<input id="phone" class="form" name="phone" type="tel" pattern="[0-9]{10}" maxlength="10"
|
||||
value="<?php echo $user['telephone']; ?>" required>
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="avatar">Image du Profil :</label>
|
||||
<input type="file" id="avatar" class="form" name="avatar" accept="image/png, image/jpeg">
|
||||
</div>
|
||||
<?php
|
||||
printError();
|
||||
?>
|
||||
<input id="submit" class="button" type="submit" value="Modifier">
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
314
WEB/profil/profil.php
Normal file
314
WEB/profil/profil.php
Normal file
@ -0,0 +1,314 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once('../connexionBD.php');
|
||||
require_once ('../ressources/user.php');
|
||||
|
||||
$mail = $_SESSION['mail'];
|
||||
$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;
|
||||
$modele = isset($_POST['modele']) ? $_POST['modele'] : NULL;
|
||||
$nbplaces = isset($_POST['nbplaces']) ? $_POST['nbplaces'] : NULL;
|
||||
$anneefab = isset($_POST['anneefab']) ? $_POST['anneefab'] : NULL;
|
||||
|
||||
function printError(){
|
||||
if (isset($_GET['error'])) {
|
||||
$erreur = getErrorProfil($_GET['error']);
|
||||
echo "<p class = 'error'>$erreur</p>";
|
||||
}
|
||||
}
|
||||
|
||||
function getErrorProfil($code){
|
||||
switch ($code) {
|
||||
case 1:
|
||||
return "Ce login est déjà associé à un compte.";
|
||||
case 2:
|
||||
return "Les mots de passe ne correspondent pas.";
|
||||
case 3:
|
||||
return "Erreur lors de la récupération des informations de profil.";
|
||||
case 4:
|
||||
return "Le fichier envoyé doit être une image au format PNG ou JPEG.";
|
||||
case 5:
|
||||
return "La taille de l'image ne doit pas dépasser 2 MB.";
|
||||
case 6:
|
||||
return "Erreur lors de la modification du compte.";
|
||||
}
|
||||
}
|
||||
|
||||
function addVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab){
|
||||
$requete = "INSERT INTO public.voiture (matricule, marque, modele, nbplaces, anneefab, mail) VALUES ('" . $matricule . "','" . $marque . "','" . $modele . "','" . $nbplaces . "','" . $anneefab . "','" . $_SESSION['mail'] . "');";
|
||||
pg_query($db, $requete);
|
||||
}
|
||||
|
||||
function changeVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab){
|
||||
$requete = "UPDATE public.voiture SET (matricule, marque, modele, nbplaces, anneefab) = ('" . $matricule . "','" . $marque . "','" . $modele . "','" . $nbplaces . "','" . $anneefab . "') WHERE mail = '" . $_SESSION['mail'] . "';";
|
||||
pg_query($db, $requete);
|
||||
}
|
||||
|
||||
function showVoiture($db){
|
||||
$requete = "SELECT * FROM public.voiture WHERE voiture.mail = '" . $_SESSION['mail'] . "';";
|
||||
if ($donnees = pg_query($db, $requete)) {
|
||||
while ($res = pg_fetch_assoc($donnees)) {
|
||||
echo "matricule = ".$res['matricule']."<br>";
|
||||
echo "marque = ".$res['marque']."<br>";
|
||||
echo "modele = ".$res['modele']."<br>";
|
||||
echo "nombre de places = ".$res['nbplaces']."<br>";
|
||||
echo "année de fabrication = ".$res['anneefab']."<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['mail'])) {
|
||||
header('Location: index.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_POST['submitadd'])) {
|
||||
addVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab);
|
||||
}
|
||||
if (isset($_POST['submitchange'])) {
|
||||
changeVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab);
|
||||
}
|
||||
|
||||
$user = getUser($db, $mail);
|
||||
|
||||
if (!$user){
|
||||
header('Location: profil.php?error=3');
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_POST['login']) || isset($_FILES['avatar'])){
|
||||
if (isset($_FILES['avatar']) and !empty($_FILES['avatar']['name'])) {
|
||||
$fic = $_FILES['avatar'];
|
||||
supprimerAvatar($mail);
|
||||
$res = uploadAvatar($mail, $fic);
|
||||
switch ($res){
|
||||
case -1:
|
||||
header('Location: profil.php?error=4');
|
||||
exit();
|
||||
case -2:
|
||||
header('Location: profil.php?error=5');
|
||||
exit();
|
||||
case -3:
|
||||
header('Location: profil.php?error=6');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
if (isset($_POST['login']) && isset($_POST['password']) && isset($_POST['confirmation']) && isset($_POST['prenom']) && isset($_POST['nom']) && isset($_POST['phone'])) {
|
||||
$login = htmlentities(pg_escape_string($_POST['login']));
|
||||
$password = htmlentities(pg_escape_string($_POST['password']));
|
||||
$confirmation = htmlentities(pg_escape_string($_POST['confirmation']));
|
||||
$prenom = htmlentities(pg_escape_string($_POST['prenom']));
|
||||
$nom = htmlentities(pg_escape_string($_POST['nom']));
|
||||
$phone = htmlentities(pg_escape_string($_POST['phone']));
|
||||
|
||||
if (loginChange($user, $login)) {
|
||||
if (!isLoginUniqueModifier($db, $mail, $login)) {
|
||||
header('Location: profil.php?error=1');
|
||||
exit();
|
||||
} else {
|
||||
if (!modifierLogin($db, $mail, $login)) {
|
||||
header('Location: profil.php?error=6');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp($password, $confirmation) != 0) {
|
||||
header('Location: profil.php?error=2');
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!modifierUtilisateur($db, $mail, $prenom, $nom, $password, $phone)) {
|
||||
header('Location: profil.php?error=6');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
sleep(0.85);
|
||||
header('Location: profil.php');
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="profil.css">
|
||||
<link rel="stylesheet" href="../ressources/navbarhtml.css">
|
||||
<link rel="stylesheet" href="../index_inscription.css">
|
||||
<script src="../inscription.js"></script>
|
||||
<title>Profil</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php require_once("../ressources/navbarhtml.php"); ?>
|
||||
<div id="formulaire">
|
||||
<h1>Profil de <?php echo $user['prenom']; ?></h1>
|
||||
<div id="divImgProfil">
|
||||
<img id="imgProfil" src="<?php echo getPathImgProfil($mail); ?>">
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
function visibilite(thingId){
|
||||
var targetElement;
|
||||
var elements;
|
||||
targetElement = document.getElementById(thingId) ;
|
||||
elements = document.getElementsByClassName("Element")
|
||||
for (var i = 0; i < elements.length; i++){
|
||||
if(!targetElement.isSameNode(elements[i])){
|
||||
elements[i].style.display = "none" ;
|
||||
}
|
||||
}
|
||||
if (targetElement.style.display == "none"){
|
||||
targetElement.style.display = "";
|
||||
}
|
||||
else{
|
||||
targetElement.style.display = "none" ;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<ul class="profil-nav">
|
||||
<li class="FT"><a href="" onclick="javascript:visibilite('profilgeneral'); return false;">Profil général</a></li>
|
||||
<li class="FT"><a href="" onclick="javascript:visibilite('profilvoiture'); return false;">Profil voiture</a></li>
|
||||
</ul>
|
||||
<div id="profilgeneral" class="Element" style="display:none;">
|
||||
<form method="post" action="profil.php" enctype="multipart/form-data">
|
||||
<div class="line">
|
||||
<label for="mail">Adresse mail : </label>
|
||||
<input id="mail" class="form" type="email" maxlength="100" readonly value="<?php echo $user['mail']; ?>">
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="login">Login : </label>
|
||||
<input id="login" class="form" name="login" type="text" maxlength="50"
|
||||
value="<?php echo $user['login']; ?>" required>
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="password">Mot de passe : </label>
|
||||
<input class="form" id="password" name="password" type="password" maxlength="50"
|
||||
value="<?php echo $user['passwd']; ?>" required>
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="confirmation">Confirmation : </label>
|
||||
<input class="form" id="confirmation" name="confirmation" type="password" maxlength="16"
|
||||
value="<?php echo $user['passwd']; ?>" required>
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="prenom">Prénom : </label>
|
||||
<input id="prenom" class="form" name="prenom" type="text" maxlength="50"
|
||||
value="<?php echo $user['prenom']; ?>" required>
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="nom">Nom : </label>
|
||||
<input id="nom" class="form" name="nom" type="text" maxlength="50" value="<?php echo $user['nom']; ?>"
|
||||
required>
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="dateN">Date de naissance : </label>
|
||||
<input id="dateN" class="form" readonly="readonly" type="date"
|
||||
value="<?php echo $user['datenaissance']; ?>" required>
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="phone">Numéro de téléphone : </label>
|
||||
<input id="phone" class="form" name="phone" type="tel" pattern="[0-9]{10}" maxlength="10"
|
||||
value="<?php echo $user['telephone']; ?>" required>
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="avatar">Image du Profil :</label>
|
||||
<input type="file" id="avatar" class="form" name="avatar" accept="image/png, image/jpeg">
|
||||
</div>
|
||||
<?php printError(); ?>
|
||||
<input id="submit" class="button" type="submit" value="Modifier">
|
||||
</form>
|
||||
</div>
|
||||
<div id="profilvoiture" class="Element" style="display:none;">
|
||||
<script type="text/javascript">
|
||||
function ShowTab(E) {
|
||||
document.getElementById("addVoiture").style.display = (E == 1) ? 'block' : 'none';
|
||||
document.getElementById("changeVoiture").style.display = (E == 2) ? 'block' : 'none';
|
||||
document.getElementById("showVoiture").style.display = (E == 3) ? 'block' : 'none';
|
||||
}
|
||||
</script>
|
||||
<form id="choixFormeTestVoiture">
|
||||
<div>
|
||||
<input type="radio" name="TabCheck" onclick="ShowTab(1)"/>Ajouter une voiture
|
||||
<input type="radio" name="TabCheck" onclick="ShowTab(2)"/>Modifier ma voiture
|
||||
<input type="radio" name="TabCheck" onclick="ShowTab(3)"/>Afficher ma voiture
|
||||
</div>
|
||||
</form>
|
||||
<div id="addVoiture" style="display: none;">
|
||||
<h1>Ajouter une voiture</h1>
|
||||
<fieldset>
|
||||
<form action="profil.php" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<td><p>matricule :</p></td>
|
||||
<td><input type="text" name="matricule"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p>marque :</p></td>
|
||||
<td><input type="text" name="marque"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p>modele :</p></td>
|
||||
<td><input type="text" name="modele"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p>nombre de places :</p></td>
|
||||
<td><input type="number" maxlength="1" name="nbplaces"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p>année de fabrication :</p></td>
|
||||
<td><input type="number" nmaxlength="4" name="anneefab"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p><input type="submit" name="submitadd" value="ajouter une voiture"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div id="changeVoiture" style="display: none;">
|
||||
<h1>Modifier une voiture</h1>
|
||||
<fieldset>
|
||||
<form action="profil.php" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<td><p>matricule :</p></td>
|
||||
<td><input type="text" name="matricule"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p>marque :</p></td>
|
||||
<td><input type="text" name="marque"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p>modele :</p></td>
|
||||
<td><input type="text" name="modele"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p>nombre de places :</p></td>
|
||||
<td><input type="number" maxlength="1" name="nbplaces"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p>année de fabrication :</p></td>
|
||||
<td><input type="number" nmaxlength="4" name="anneefab"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p><input type="submit" name="submitchange" value="modifier une voiture"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div id="showVoiture" style="display: none;">
|
||||
<h1>Afficher ma voiture</h1>
|
||||
<fieldset>
|
||||
<form action="profil.php" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<td><p><input type="submit" name="submitshow" value="afficher ma voiture"></p></td>
|
||||
<?php if (isset($_POST['submitshow'])) { showVoiture($db); }?>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,10 +1,8 @@
|
||||
<?php
|
||||
|
||||
$path = "..";
|
||||
if (file_exists("./inscription.php")) {
|
||||
$path = ".";
|
||||
}
|
||||
|
||||
?>
|
||||
<div id="menuDiv">
|
||||
<nav id="menu">
|
||||
@ -14,7 +12,7 @@ if (file_exists("./inscription.php")) {
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Messagerie</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Avis reçus</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Avis laissés</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/profil.php">Profil</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/profil/profil.php">Profil</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/deconnexion.php">Se déconnecter</a>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -57,7 +57,7 @@ function getLogin($db, $mail)
|
||||
|
||||
function getPathImgProfilTableau($mail)
|
||||
{
|
||||
$list = scandir($_SERVER['DOCUMENT_ROOT'] . "/imageProfil");
|
||||
$list = scandir($_SERVER['DOCUMENT_ROOT'] . "../imageProfil");
|
||||
foreach ($list as $entry) {
|
||||
if (strpos($entry, $mail) !== false) {
|
||||
return "../imageProfil/$entry";
|
||||
@ -68,21 +68,21 @@ function getPathImgProfilTableau($mail)
|
||||
|
||||
function getPathImgProfil($mail)
|
||||
{
|
||||
$list = scandir($_SERVER['DOCUMENT_ROOT'] . "/imageProfil");
|
||||
$list = scandir($_SERVER['DOCUMENT_ROOT'] . "../imageProfil");
|
||||
foreach ($list as $entry) {
|
||||
if (strpos($entry, $mail) !== false) {
|
||||
return "./imageProfil/$entry";
|
||||
return "/./imageProfil/$entry";
|
||||
}
|
||||
}
|
||||
return "./imageProfil/default.svg";
|
||||
return "../imageProfil/default.svg";
|
||||
}
|
||||
|
||||
function supprimerAvatar($mail)
|
||||
{
|
||||
$list = scandir($_SERVER['DOCUMENT_ROOT'] . "/imageProfil");
|
||||
$list = scandir($_SERVER['DOCUMENT_ROOT'] . "../imageProfil");
|
||||
foreach ($list as $entry) {
|
||||
if (strpos($entry, $mail) !== false) {
|
||||
unlink($_SERVER['DOCUMENT_ROOT'] . "/imageProfil/$entry");
|
||||
unlink($_SERVER['DOCUMENT_ROOT'] . "../imageProfil/$entry");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -117,7 +117,7 @@ function uploadAvatar($mail, $fic)
|
||||
{
|
||||
$tmp = explode('.', $fic['name']);
|
||||
$extension = end($tmp);
|
||||
$target_file = "./imageProfil/$mail.$extension";
|
||||
$target_file = "../imageProfil/$mail.$extension";
|
||||
$file_tmp = $fic['tmp_name'];
|
||||
$check = getimagesize($file_tmp);
|
||||
if ($check === false or !in_array($extension, array('png', 'jpg', 'jpeg', 'pjpeg', 'jfif', 'pjp'))) {
|
||||
@ -130,4 +130,4 @@ function uploadAvatar($mail, $fic)
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -12,22 +12,6 @@ if (!isset($_SESSION['mail'])) {
|
||||
}
|
||||
$mail = $_SESSION['mail'];
|
||||
|
||||
$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;
|
||||
$modele = isset($_POST['modele']) ? $_POST['modele'] : NULL;
|
||||
$nbplaces = isset($_POST['nbplaces']) ? $_POST['nbplaces'] : NULL;
|
||||
$anneefab = isset($_POST['anneefab']) ? $_POST['anneefab'] : NULL;
|
||||
|
||||
if (isset($_POST['submitadd'])) {
|
||||
addVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab);
|
||||
}
|
||||
if (isset($_POST['submitchange'])) {
|
||||
changeVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab);
|
||||
}
|
||||
if (isset($_POST['submitshow'])) {
|
||||
showVoiture($db);
|
||||
}
|
||||
|
||||
function getTrajetsProposes($db, $mail)
|
||||
{
|
||||
$result = pg_query_params($db, "SELECT COUNT(*) from Trajet WHERE mailProposition = $1 AND estAnnule = false AND datedepart >= current_date;", array($mail));
|
||||
@ -68,34 +52,6 @@ function getAvisNonLus($db, $mail)
|
||||
return $login;
|
||||
}
|
||||
}
|
||||
|
||||
function addVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab)
|
||||
{
|
||||
$requete = "INSERT INTO public.voiture (matricule, marque, modele, nbplaces, anneefab, mail) VALUES ('" . $matricule . "','" . $marque . "','" . $modele . "','" . $nbplaces . "','" . $anneefab . "','" . $_SESSION['mail'] . "');";
|
||||
pg_query($db, $requete);
|
||||
}
|
||||
|
||||
function changeVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab)
|
||||
{
|
||||
$requete = "UPDATE public.voiture SET (matricule, marque, modele, nbplaces, anneefab) = ('" . $matricule . "','" . $marque . "','" . $modele . "','" . $nbplaces . "','" . $anneefab . "') WHERE mail = '" . $_SESSION['mail'] . "';";
|
||||
echo "requete =" . $requete;
|
||||
pg_query($db, $requete);
|
||||
}
|
||||
|
||||
function showVoiture($db)
|
||||
{
|
||||
$requete = "SELECT * FROM public.voiture WHERE voiture.mail = '" . $_SESSION['mail'] . "';";
|
||||
if ($donnees = pg_query($db, $requete)) {
|
||||
while ($res = pg_fetch_assoc($donnees)) {
|
||||
echo "matricule = " . $res['matricule'] . "<br>";
|
||||
echo "marque = " . $res['marque'] . "<br>";
|
||||
echo "modele = " . $res['modele'] . "<br>";
|
||||
echo "nombre de places = " . $res['nbplaces'] . "<br>";
|
||||
echo "année de fabrication = " . $res['anneefab'] . "<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
@ -108,13 +64,6 @@ function showVoiture($db)
|
||||
</head>
|
||||
<body>
|
||||
<?php require('../ressources/navbarhtml.php'); ?>
|
||||
<script type="text/javascript">
|
||||
function ShowTab(E) {
|
||||
document.getElementById("addVoiture").style.display = (E == 1) ? 'block' : 'none';
|
||||
document.getElementById("changeVoiture").style.display = (E == 2) ? 'block' : 'none';
|
||||
document.getElementById("showVoiture").style.display = (E == 3) ? 'block' : 'none';
|
||||
}
|
||||
</script>
|
||||
<div id="content">
|
||||
<div id="tableauBord">
|
||||
<h1>Bienvenue <?php echo getLogin($db, $mail); ?></h1>
|
||||
@ -143,89 +92,6 @@ function showVoiture($db)
|
||||
<p>Vous avez <?php echo getAvisNonLus($db, $mail); ?> avis non lus.</p>
|
||||
</div>
|
||||
</div>
|
||||
<form id="choixFormeTestVoiture">
|
||||
<div>
|
||||
<input type="radio" name="TabCheck" onclick="ShowTab(1)"/>Ajouter une voiture
|
||||
<input type="radio" name="TabCheck" onclick="ShowTab(2)"/>Modifier ma voiture
|
||||
<input type="radio" name="TabCheck" onclick="ShowTab(3)"/>Afficher ma voiture
|
||||
</div>
|
||||
</form>
|
||||
<div id="addVoiture" style="display: none;">
|
||||
<h1>Ajouter une voiture</h1>
|
||||
<fieldset>
|
||||
<form action="tableauBord.php" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<td><p>matricule :</p></td>
|
||||
<td><input type="text" name="matricule"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p>marque :</p></td>
|
||||
<td><input type="text" name="marque"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p>modele :</p></td>
|
||||
<td><input type="text" name="modele"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p>nombre de places :</p></td>
|
||||
<td><input type="number" maxlength="1" name="nbplaces"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p>année de fabrication :</p></td>
|
||||
<td><input type="number" nmaxlength="4" name="anneefab"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p><input type="submit" name="submitadd" value="ajouter une voiture"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div id="changeVoiture" style="display: none;">
|
||||
<h1>Modifier une voiture</h1>
|
||||
<fieldset>
|
||||
<form action="tableauBord.php" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<td><p>matricule :</p></td>
|
||||
<td><input type="text" name="matricule"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p>marque :</p></td>
|
||||
<td><input type="text" name="marque"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p>modele :</p></td>
|
||||
<td><input type="text" name="modele"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p>nombre de places :</p></td>
|
||||
<td><input type="number" maxlength="1" name="nbplaces"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p>année de fabrication :</p></td>
|
||||
<td><input type="number" nmaxlength="4" name="anneefab"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p><input type="submit" name="submitchange" value="modifier une voiture"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div id="showVoiture" style="display: none;">
|
||||
<h1>Afficher ma voiture</h1>
|
||||
<fieldset>
|
||||
<form action="tableauBord.php" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<td><p><input type="submit" name="submitshow" value="afficher ma voiture"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user