2019-04-18 18:37:23 +02:00
|
|
|
<?php
|
2019-05-10 10:23:27 +02:00
|
|
|
session_start();
|
2019-05-21 16:06:03 +02:00
|
|
|
require_once('../connexionBD.php');
|
|
|
|
require_once('../ressources/user.php');
|
2019-05-10 10:23:27 +02:00
|
|
|
|
2019-05-22 15:33:25 +02:00
|
|
|
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']));
|
2019-05-10 10:23:27 +02:00
|
|
|
|
2019-05-22 15:33:25 +02:00
|
|
|
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();
|
2019-05-18 00:40:45 +02:00
|
|
|
}
|
2019-05-22 15:33:25 +02:00
|
|
|
}
|
|
|
|
$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();
|
|
|
|
}
|
2019-05-10 10:23:27 +02:00
|
|
|
}
|
2019-05-22 15:33:25 +02:00
|
|
|
}
|
|
|
|
}
|
2019-05-18 00:40:45 +02:00
|
|
|
}
|
|
|
|
else {
|
2019-05-22 15:33:25 +02:00
|
|
|
header('Location: ../tableauBord/tableauBord.php');
|
|
|
|
exit();
|
2019-05-10 10:23:27 +02:00
|
|
|
}
|
2019-04-18 18:37:23 +02:00
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="fr">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
2019-05-21 16:06:03 +02:00
|
|
|
<link rel="stylesheet" href="inscription.css">
|
2019-04-18 18:37:23 +02:00
|
|
|
<title>Inscription</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
2019-04-28 14:53:08 +02:00
|
|
|
<div id="formulaire">
|
|
|
|
<h1>Inscription</h1>
|
|
|
|
<form method="post" enctype="multipart/form-data" action="inscription.php">
|
|
|
|
<div class="line">
|
2019-05-18 00:40:45 +02:00
|
|
|
<label for="mail">Adresse mail : </label>
|
|
|
|
<input id="mail" class="form" name="mail" type="email" maxlength="100" required>
|
2019-04-28 14:53:08 +02:00
|
|
|
</div>
|
|
|
|
<div class="line">
|
2019-05-18 00:40:45 +02:00
|
|
|
<label for="login">Login : </label>
|
|
|
|
<input id="login" class="form" name="login" type="text" maxlength="50" required>
|
2019-04-28 14:53:08 +02:00
|
|
|
</div>
|
|
|
|
<div class="line">
|
|
|
|
<label for="password">Mot de passe : </label>
|
|
|
|
<input class="form" id="password" name="password" type="password" maxlength="50" required>
|
|
|
|
</div>
|
|
|
|
<div class="line">
|
|
|
|
<label for="confirmation">Confirmation : </label>
|
|
|
|
<input class="form" id="confirmation" name="confirmation" type="password" maxlength="16">
|
|
|
|
</div>
|
|
|
|
<div class="line">
|
2019-05-18 00:40:45 +02:00
|
|
|
<label for="prenom">Prénom : </label>
|
|
|
|
<input id="prenom" class="form" name="prenom" type="text" maxlength="50" required>
|
2019-04-28 14:53:08 +02:00
|
|
|
</div>
|
|
|
|
<div class="line">
|
2019-05-18 00:40:45 +02:00
|
|
|
<label for="nom">Nom : </label>
|
|
|
|
<input id="nom" class="form" name="nom" type="text" maxlength="50" required>
|
2019-04-28 14:53:08 +02:00
|
|
|
</div>
|
|
|
|
<div class="line">
|
2019-05-18 00:40:45 +02:00
|
|
|
<label for="dateN">Date de naissance : </label>
|
|
|
|
<input id="dateN" class="form" name="dateN" type="date" required>
|
2019-04-28 14:53:08 +02:00
|
|
|
</div>
|
|
|
|
<div class="line">
|
2019-05-18 00:40:45 +02:00
|
|
|
<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" required>
|
2019-04-28 14:53:08 +02:00
|
|
|
</div>
|
|
|
|
<div class="line">
|
|
|
|
<label for="avatar">Image du Profil :</label>
|
2019-05-18 00:40:45 +02:00
|
|
|
<input type="file" id="avatar" class="form" name="avatar" accept="image/png, image/jpeg">
|
2019-04-28 14:53:08 +02:00
|
|
|
</div>
|
2019-05-22 15:33:25 +02:00
|
|
|
<?php getErrorInscription($_GET['error']); ?>
|
2019-04-28 14:53:08 +02:00
|
|
|
<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>
|
|
|
|
</div>
|
2019-05-18 00:40:45 +02:00
|
|
|
<script src="inscription.js"></script>
|
2019-04-18 18:37:23 +02:00
|
|
|
</body>
|
2019-05-21 16:06:03 +02:00
|
|
|
</html>
|