added comments

master
Flavien Haas 6 years ago
parent 0d256c60ef
commit c139f83edf

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

Loading…
Cancel
Save