|
|
|
@ -3,61 +3,62 @@ session_start();
|
|
|
|
|
require_once('../connexionBD.php');
|
|
|
|
|
require_once('../ressources/user.php');
|
|
|
|
|
|
|
|
|
|
if (!isset($_SESSION['mail'])) {
|
|
|
|
|
if (isset($_POST['login']) || isset($_FILES['avatar'])) {
|
|
|
|
|
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']));
|
|
|
|
|
$prenom = htmlentities(pg_escape_string($_POST['prenom']));
|
|
|
|
|
$nom = htmlentities(pg_escape_string($_POST['nom']));
|
|
|
|
|
$dateN = htmlentities(pg_escape_string($_POST['dateN']));
|
|
|
|
|
$mail = strtolower(htmlentities(pg_escape_string($_POST['mail'])));
|
|
|
|
|
$phone = htmlentities(pg_escape_string($_POST['phone']));
|
|
|
|
|
|
|
|
|
|
if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) {
|
|
|
|
|
header('Location: inscription.php?error=1');
|
|
|
|
|
exit();
|
|
|
|
|
} elseif (!isMailUnique($db, $mail)) {
|
|
|
|
|
header('Location: inscription.php?error=2');
|
|
|
|
|
exit();
|
|
|
|
|
} elseif (!isLoginUnique($db, $login)) {
|
|
|
|
|
header('Location: inscription.php?error=3');
|
|
|
|
|
exit();
|
|
|
|
|
} else {
|
|
|
|
|
if (isset($_FILES['avatar']) and !empty($_FILES['avatar']['name'])) {
|
|
|
|
|
$fic = $_FILES['avatar'];
|
|
|
|
|
$res = uploadAvatar($mail, $fic);
|
|
|
|
|
switch ($res){
|
|
|
|
|
case -1:
|
|
|
|
|
header('Location: inscription.php?error=4');
|
|
|
|
|
exit();
|
|
|
|
|
case -2:
|
|
|
|
|
header('Location: inscription.php?error=5');
|
|
|
|
|
exit();
|
|
|
|
|
case -3:
|
|
|
|
|
header('Location: inscription.php?error=6');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$result = creerUtilisateur($db, $mail, $password, $prenom, $nom, $login, $phone, $dateN);
|
|
|
|
|
if ($result) {
|
|
|
|
|
header('Location: ../index.php');
|
|
|
|
|
exit();
|
|
|
|
|
} else {
|
|
|
|
|
header('Location: inscription.php?error=6');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!isset($_SESSION['mail'])){
|
|
|
|
|
if (isset($_POST['login']) || isset($_FILES['avatar'])){
|
|
|
|
|
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']));
|
|
|
|
|
$prenom = htmlentities(pg_escape_string($_POST['prenom']));
|
|
|
|
|
$nom = htmlentities(pg_escape_string($_POST['nom']));
|
|
|
|
|
$dateN = htmlentities(pg_escape_string($_POST['dateN']));
|
|
|
|
|
$mail = strtolower(htmlentities(pg_escape_string($_POST['mail'])));
|
|
|
|
|
$phone = htmlentities(pg_escape_string($_POST['phone']));
|
|
|
|
|
|
|
|
|
|
if (!filter_var($mail, FILTER_VALIDATE_EMAIL)){
|
|
|
|
|
header('Location: inscription.php?error=1');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
elseif (!isMailUnique($db, $mail)){
|
|
|
|
|
header('Location: inscription.php?error=2');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
elseif (!isLoginUnique($db, $login)){
|
|
|
|
|
header('Location: inscription.php?error=3');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (isset($_FILES['avatar']) and !empty($_FILES['avatar']['name'])) {
|
|
|
|
|
$fic = $_FILES['avatar'];
|
|
|
|
|
$res = uploadAvatar($mail, $fic);
|
|
|
|
|
switch ($res){
|
|
|
|
|
case -1:
|
|
|
|
|
header('Location: inscription.php?error=4');
|
|
|
|
|
exit();
|
|
|
|
|
case -2:
|
|
|
|
|
header('Location: inscription.php?error=5');
|
|
|
|
|
exit();
|
|
|
|
|
case -3:
|
|
|
|
|
header('Location: inscription.php?error=6');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$result = creerUtilisateur($db, $mail, $password, $prenom, $nom, $login, $phone, $dateN);
|
|
|
|
|
if ($result) {
|
|
|
|
|
header('Location: ../index.php');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
header('Location: inscription.php?error=6');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
header('Location: ../tableauBord/tableauBord.php');
|
|
|
|
|
exit();
|
|
|
|
|
header('Location: ../tableauBord/tableauBord.php');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="fr">
|
|
|
|
@ -106,9 +107,7 @@ else {
|
|
|
|
|
<label for="avatar">Image du Profil :</label>
|
|
|
|
|
<input type="file" id="avatar" class="form" name="avatar" accept="image/png, image/jpeg">
|
|
|
|
|
</div>
|
|
|
|
|
<?php
|
|
|
|
|
printError();
|
|
|
|
|
?>
|
|
|
|
|
<?php getErrorInscription($_GET['error']); ?>
|
|
|
|
|
<input id="submit" class="button" type="submit" value="S'inscrire">
|
|
|
|
|
</form>
|
|
|
|
|
<p id="enregistrer">Si vous avez déjà un compte <a href="index.php" title="S'identifier">cliquez ici</a>.</p>
|
|
|
|
|