Base auth
This commit is contained in:
@@ -1,9 +1,47 @@
|
||||
<?php
|
||||
|
||||
if(isset($_POST['auth'])
|
||||
session_start();
|
||||
if(isset($_SESSION['auth']))
|
||||
{
|
||||
$mail = filter_input(INPUT_POST, 'mail', FILTER_VALIDATE_EMAIL | FILTER_SANITIZE_EMAIL);
|
||||
|
||||
header('Location: ../../');
|
||||
}
|
||||
|
||||
if(isset($_POST['auth']))
|
||||
{
|
||||
$login = filter_input(INPUT_POST, 'login', FILTER_SANITIZE_STRING);
|
||||
|
||||
if($mail)
|
||||
{
|
||||
$pass = filter_input(INPUT_POST, 'passwd', FILTER_SANITIZE_STRING);
|
||||
|
||||
$data = getInfos($mail);
|
||||
|
||||
if(password_verify($pass, $data['passwd']))
|
||||
{
|
||||
session_start();
|
||||
$_SESSION['login'] = $data['login'];
|
||||
$_SESSION['name'] = $data['name'];
|
||||
$_SESSION['auth'] = true;
|
||||
|
||||
header('Location: ../../');
|
||||
}
|
||||
}
|
||||
|
||||
$error = "Mauvais login et/ou mot de passe";
|
||||
session_destroy();
|
||||
}
|
||||
|
||||
include "../templates/header.php";
|
||||
?>
|
||||
<form method="POST">
|
||||
<label for="login">Login</label>
|
||||
<input type="text" id="login" name="login" placeholder="Votre identifiant" required value="<?php if($error) echo $_POST['login'] ?>" />
|
||||
<label for="passwd">Mot de passe</label>
|
||||
<input type="passwd" id="passwd" name="passwd" placeholder="Votre mot de passe" minlength="6" required value="<?php if($error) echo $_POST['passwd'] ?>" />
|
||||
<input type="hidden" name="auth" value="true" />
|
||||
<input type="submit" value="valider">
|
||||
</form>
|
||||
|
||||
<a href="register.php">Pas de compte ? Inscrivez-vous ! </a>
|
||||
|
||||
<?php include "../templates/footer.php" ?>
|
||||
|
Reference in New Issue
Block a user