|
|
|
@@ -0,0 +1,99 @@ |
|
|
|
<?php |
|
|
|
include('inc/core.php'); |
|
|
|
if(isLogged()){ |
|
|
|
header('Location: index.php'); |
|
|
|
die('<a href="login.php">Cliquez ici si vous n\'êtes pas redirigé automatiquement'); |
|
|
|
} |
|
|
|
if (isset($_POST['inputEmail']) && isset($_POST['inputPassword']) && isset($_POST['inputLastname']) && isset($_POST['inputFirstname'])) { |
|
|
|
$login = filter_input(INPUT_POST, 'inputEmail'); |
|
|
|
$password = hash('sha256', filter_input(INPUT_POST, 'inputPassword')); |
|
|
|
|
|
|
|
$Pdostatinscripton = $mysql->prepare('INSERT INTO users VALUES (NULL, :mail, :motdepasse, :nom, :prenom)'); |
|
|
|
|
|
|
|
$Pdostatinscripton->bindValue(':mail',$login, PDO::PARAM_STR); |
|
|
|
$Pdostatinscripton->bindValue(':motdepasse', $password, PDO::PARAM_STR); |
|
|
|
$Pdostatinscripton->bindValue(':nom',filter_input(INPUT_POST, 'inputLastname'), PDO::PARAM_STR); |
|
|
|
$Pdostatinscripton->bindValue(':prenom',filter_input(INPUT_POST, 'inputFirstname'), PDO::PARAM_STR); |
|
|
|
|
|
|
|
$insertIsOk = $Pdostatinscripton->execute(); |
|
|
|
|
|
|
|
if ($insertIsOk) // Inscription Ok ! |
|
|
|
{ |
|
|
|
$_SESSION['login'] = $login; |
|
|
|
$_SESSION['id'] = $mysql->lastInsertId(); |
|
|
|
$_SESSION['password'] = $password; |
|
|
|
$message = $_SESSION['message'] = 'Vous êtes désormais inscrit !'; |
|
|
|
$message_type = $_SESSION['message_type'] = 'success'; |
|
|
|
$message_redirect = true; |
|
|
|
header('Location: index.php'); |
|
|
|
} else // Acces pas OK ! |
|
|
|
{ |
|
|
|
$message = 'Une erreur s\'est produite lors de votre inscription. Réessayez plus tard.'; |
|
|
|
$message_type = "danger"; |
|
|
|
} |
|
|
|
$query->CloseCursor(); |
|
|
|
|
|
|
|
} |
|
|
|
?> |
|
|
|
<!doctype html> |
|
|
|
<html lang="fr"> |
|
|
|
<head> |
|
|
|
<meta charset="utf-8"> |
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
|
|
|
<meta name="description" content=""> |
|
|
|
<meta name="author" content=""> |
|
|
|
<link rel="icon" href="img/favicon.ico"> |
|
|
|
|
|
|
|
<title>Le coin des g@mers - Identification</title> |
|
|
|
|
|
|
|
<link rel="canonical" href="https://getbootstrap.com/docs/4.0/examples/sign-in/"> |
|
|
|
|
|
|
|
<!-- Bootstrap core CSS --> |
|
|
|
<link href="css/bootstrap.min.css" rel="stylesheet"> |
|
|
|
|
|
|
|
<!-- Custom styles for this template --> |
|
|
|
<link href="css/login.css" rel="stylesheet"> |
|
|
|
</head> |
|
|
|
|
|
|
|
<body class="text-center"> |
|
|
|
|
|
|
|
<form class="form-signin" method="post"> |
|
|
|
<img class="mb-4" src="https://getbootstrap.com/docs/4.0/assets/brand/bootstrap-solid.svg" alt="" width="72" |
|
|
|
height="72"> |
|
|
|
<h1 class="h3 mb-3 font-weight-normal">Identification</h1> |
|
|
|
<?php if (isset($message) or isset($_SESSION['message'])) { ?> |
|
|
|
<div class="alert alert-<?php if (isset($message)) { echo $message_type; } else {echo $_SESSION['message_type'];} ?>" role="alert"> |
|
|
|
<?php |
|
|
|
if (isset($message)) { |
|
|
|
echo $message; |
|
|
|
} else { |
|
|
|
echo $_SESSION['message']; |
|
|
|
|
|
|
|
if($message_redirect = true){ echo ' <a href="index.php">Il semble que vous n\'avez pas été redirigé. Cliquez ici pour retourner à l\'accueil.</a>'; } |
|
|
|
unset($_SESSION['message']); |
|
|
|
unset($_SESSION['message_type']); |
|
|
|
} |
|
|
|
?> |
|
|
|
</div> |
|
|
|
<?php } ?> |
|
|
|
<label for="inputEmail" class="sr-only">Email</label> |
|
|
|
<input type="email" id="inputEmail" name="inputEmail" class="form-control" placeholder="Email" required autofocus> |
|
|
|
|
|
|
|
<label for="inputLastname" class="sr-only">Nom</label> |
|
|
|
<input type="text" id="inputLastname" name="inputLastname" class="form-control" placeholder="Nom" required autofocus> |
|
|
|
|
|
|
|
<label for="inputFirstname" class="sr-only">Prénom</label> |
|
|
|
<input type="text" id="inputFirstname" name="inputFirstname" class="form-control" placeholder="Prénom" required autofocus> |
|
|
|
|
|
|
|
<label for="inputPassword" class="sr-only">Mot de passe</label> |
|
|
|
<input type="password" id="inputPassword" name="inputPassword" class="form-control" placeholder="Mot de passe" |
|
|
|
required> |
|
|
|
|
|
|
|
<button class="btn btn-lg btn-primary btn-block" type="submit">Connexion</button> |
|
|
|
<br> |
|
|
|
<a class="mt-5 mb-3" href="register.php">S'inscrire</a> |
|
|
|
<p class="mt-5 mb-3 text-muted">© 2020</p> |
|
|
|
</form> |
|
|
|
|
|
|
|
</body> |
|
|
|
</html> |