|
|
@ -2,6 +2,7 @@
|
|
|
|
session_start();
|
|
|
|
session_start();
|
|
|
|
require_once('../connexionBD.php');
|
|
|
|
require_once('../connexionBD.php');
|
|
|
|
require_once ('../ressources/user.php');
|
|
|
|
require_once ('../ressources/user.php');
|
|
|
|
|
|
|
|
require_once ('../ressources/verifconnecte.php');
|
|
|
|
require_once ('../ressources/voiture.php');
|
|
|
|
require_once ('../ressources/voiture.php');
|
|
|
|
|
|
|
|
|
|
|
|
$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"
|
|
|
@ -10,13 +11,7 @@ $modele = isset($_POST['modele']) ? $_POST['modele'] : NULL;
|
|
|
|
$nbplaces = isset($_POST['nbplaces']) ? $_POST['nbplaces'] : NULL;
|
|
|
|
$nbplaces = isset($_POST['nbplaces']) ? $_POST['nbplaces'] : NULL;
|
|
|
|
$anneefab = isset($_POST['anneefab']) ? $_POST['anneefab'] : NULL;
|
|
|
|
$anneefab = isset($_POST['anneefab']) ? $_POST['anneefab'] : NULL;
|
|
|
|
|
|
|
|
|
|
|
|
if (!isset($_SESSION['mail'])) {
|
|
|
|
if (isset($_POST['submitadd'])) { //si formulaire pressé appele la methode
|
|
|
|
header('Location: index.php');
|
|
|
|
|
|
|
|
exit();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$mail = $_SESSION['mail'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($_POST['submitadd'])) {
|
|
|
|
|
|
|
|
$result = pg_query_params($db, "SELECT COUNT(*), matricule FROM voiture WHERE mail = $1 GROUP BY matricule;", array($mail));
|
|
|
|
$result = pg_query_params($db, "SELECT COUNT(*), matricule FROM voiture WHERE mail = $1 GROUP BY matricule;", array($mail));
|
|
|
|
$row = pg_fetch_array($result);
|
|
|
|
$row = pg_fetch_array($result);
|
|
|
|
if($row[0] == 0){
|
|
|
|
if($row[0] == 0){
|
|
|
@ -34,12 +29,12 @@ if (!$user){
|
|
|
|
exit();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($_POST['login']) || isset($_FILES['avatar'])){
|
|
|
|
if (isset($_POST['login']) || isset($_FILES['avatar'])){ //si connecte ou si avatar de defini
|
|
|
|
if (isset($_FILES['avatar']) and !empty($_FILES['avatar']['name'])) {
|
|
|
|
if (isset($_FILES['avatar']) and !empty($_FILES['avatar']['name'])) { //si avatar et pas de fichier au nom de l'utilisateur
|
|
|
|
$fic = $_FILES['avatar'];
|
|
|
|
$fic = $_FILES['avatar']; //avatar envoyé par l'utilisateur
|
|
|
|
supprimerAvatar($mail);
|
|
|
|
supprimerAvatar($mail); //supprime l'avatar courant de l'utilisateur
|
|
|
|
$res = uploadAvatar($mail, $fic);
|
|
|
|
$res = uploadAvatar($mail, $fic); //enregistre l'avatar avec le mail de l'utilisateur
|
|
|
|
switch ($res){
|
|
|
|
switch ($res){ //controle d'erreur de la fonction uploadAvatar
|
|
|
|
case -1:
|
|
|
|
case -1:
|
|
|
|
header('Location: profil.php?error=4');
|
|
|
|
header('Location: profil.php?error=4');
|
|
|
|
exit();
|
|
|
|
exit();
|
|
|
@ -51,8 +46,8 @@ if (isset($_POST['login']) || isset($_FILES['avatar'])){
|
|
|
|
exit();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($_POST['login']) && isset($_POST['password']) && isset($_POST['confirmation']) && isset($_POST['prenom']) && isset($_POST['nom']) && isset($_POST['phone'])) {
|
|
|
|
if (isset($_POST['login']) && isset($_POST['password']) && isset($_POST['confirmation']) && isset($_POST['prenom']) && isset($_POST['nom']) && isset($_POST['phone'])) { //controle du remplissage du formulaire
|
|
|
|
$login = htmlentities(pg_escape_string($_POST['login']));
|
|
|
|
$login = htmlentities(pg_escape_string($_POST['login'])); //recupere la variable du formulaire
|
|
|
|
$password = htmlentities(pg_escape_string($_POST['password']));
|
|
|
|
$password = htmlentities(pg_escape_string($_POST['password']));
|
|
|
|
$confirmation = htmlentities(pg_escape_string($_POST['confirmation']));
|
|
|
|
$confirmation = htmlentities(pg_escape_string($_POST['confirmation']));
|
|
|
|
$prenom = htmlentities(pg_escape_string($_POST['prenom']));
|
|
|
|
$prenom = htmlentities(pg_escape_string($_POST['prenom']));
|
|
|
|