Base auth
This commit is contained in:
parent
a3fcf1beeb
commit
20055cc57e
13
index.php
13
index.php
@ -1,17 +1,4 @@
|
|||||||
<?php include "php/templates/header.php" ?>
|
<?php include "php/templates/header.php" ?>
|
||||||
<body>
|
|
||||||
<nav>
|
|
||||||
<div>
|
|
||||||
<h1 id="titre">AIide, site d'aide aux étudiants</h1>
|
|
||||||
<ul>
|
|
||||||
<li><a href="">Matières</a></li>
|
|
||||||
<li><a href="">A propos</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div id="auth">
|
|
||||||
<a href="">Se connecter</a>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
<div>
|
<div>
|
||||||
<p>Coucou c'est le service d'aide aux BUT Info</p>
|
<p>Coucou c'est le service d'aide aux BUT Info</p>
|
||||||
</div>
|
</div>
|
||||||
|
0
js/register.js
Normal file
0
js/register.js
Normal file
@ -1,9 +1,47 @@
|
|||||||
<?php
|
<?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" ?>
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
session_destroy();
|
||||||
|
header('Location: ../../')
|
||||||
|
?>
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
if(isset($_SESSION['auth']))
|
||||||
|
{
|
||||||
|
header('Location: ../../');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_POST['register']))
|
||||||
|
{
|
||||||
|
$mail = filter_input(INPUT_POST, 'mail', FILTER_VALIDATE_EMAIL | FILTER_SANITIZE_EMAIL);
|
||||||
|
|
||||||
|
if($mail)
|
||||||
|
{
|
||||||
|
$pass = filter_input(INPUT_POST, 'passwd', FILTER_SANITIZE_STRING);
|
||||||
|
|
||||||
|
// A continuer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
include "../templates/header.php";
|
||||||
|
?>
|
||||||
|
<form method="POST">
|
||||||
|
<label for="mail">mail</label>
|
||||||
|
<input type="email" id="mail" name="mail" placeholder="Votre identifiant" required value="<?php if($error) echo $_POST['mail'] ?>"/>
|
||||||
|
<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'] ?>" />
|
||||||
|
<label for="conf_passwd">Confirmer votre mot de passe</label>
|
||||||
|
<input type="passwd" id="conf_passwd" name="conf_passwd" placeholder="Confirmation du mot de passe" minlength="6" required />
|
||||||
|
<input type="hidden" name="register" value="true" />
|
||||||
|
<input type="submit" value="valider">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<a href="login.php">Déjà inscrit ? Connectez-vous !</a>
|
||||||
|
|
||||||
|
<?php include "../templates/footer.php" ?>
|
@ -5,3 +5,16 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
|
||||||
<title>AIidE</title>
|
<title>AIidE</title>
|
||||||
</head>
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav>
|
||||||
|
<div>
|
||||||
|
<h1 id="titre">AIide, site d'aide aux étudiants</h1>
|
||||||
|
<ul>
|
||||||
|
<li><a href="">Matières</a></li>
|
||||||
|
<li><a href="">A propos</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div id="auth">
|
||||||
|
<a href="php/auth/login.php">Se connecter</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
0
res/test.txt
Normal file
0
res/test.txt
Normal file
Loading…
Reference in New Issue
Block a user