46 lines
1.6 KiB
PHP
46 lines
1.6 KiB
PHP
<?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)
|
||
{
|
||
$promo = filter_input(INPUT_POST, 'promo', FILTER_VALIDATE_INT | FILTER_SANITIZE_NUMBER_INT);
|
||
|
||
if($promo)
|
||
{
|
||
$pass = filter_input(INPUT_POST, 'passwd', FILTER_SANITIZE_STRING);
|
||
|
||
register($mail, $promo, password_hash($pass, PASSWORD_DEFAULT));
|
||
|
||
header("Location: login.php");
|
||
}
|
||
}
|
||
}
|
||
|
||
include "../templates/header.php";
|
||
?>
|
||
<form method="POST">
|
||
<label for="mail">Mail</label>
|
||
<input type="email" id="mail" name="mail" placeholder="Votre adresse mail" required value="<?php if(isset($error)) echo $_POST['mail'] ?>"/>
|
||
<label for="promo">Promo</label>
|
||
<input type="number" id="promo" name="promo" placeholder="Votre année de sortie du BUT" required min="1996" max="<?php $now = date("Y") + 3; echo $now; ?>" />
|
||
<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(isset($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" ?>
|