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