SQL
This commit is contained in:
parent
78f8376033
commit
3ba56a592a
@ -0,0 +1,10 @@
|
|||||||
|
window.addEventListener("load", function () {
|
||||||
|
let passwd = this.document.getElementById("passwd");
|
||||||
|
let passwd_conf = this.document.getElementById("conf_passwd");
|
||||||
|
|
||||||
|
passwd_conf.addEventListener("change", function(){
|
||||||
|
this.style.border += "red";
|
||||||
|
let error = document.getElementById("error");
|
||||||
|
error.style.display = "block";
|
||||||
|
});
|
||||||
|
});
|
@ -11,18 +11,27 @@
|
|||||||
$mail = filter_input(INPUT_POST, 'mail', FILTER_VALIDATE_EMAIL | FILTER_SANITIZE_EMAIL);
|
$mail = filter_input(INPUT_POST, 'mail', FILTER_VALIDATE_EMAIL | FILTER_SANITIZE_EMAIL);
|
||||||
|
|
||||||
if($mail)
|
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);
|
$pass = filter_input(INPUT_POST, 'passwd', FILTER_SANITIZE_STRING);
|
||||||
|
|
||||||
// A continuer
|
register($mail, $promo, password_hash($pass, PASSWORD_DEFAULT));
|
||||||
|
|
||||||
|
header("Location: login.php");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
include "../templates/header.php";
|
include "../templates/header.php";
|
||||||
?>
|
?>
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<label for="mail">mail</label>
|
<label for="mail">Mail</label>
|
||||||
<input type="email" id="mail" name="mail" placeholder="Votre identifiant" required value="<?php if(isset($error)) echo $_POST['mail'] ?>"/>
|
<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>
|
<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'] ?>" />
|
<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>
|
<label for="conf_passwd">Confirmer votre mot de passe</label>
|
||||||
|
39
php/utilities/functions.php
Normal file
39
php/utilities/functions.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$dbh = new PDO('mysql:host=dwarves.iut-bleau.fr;dbname=dupard', "dupard", "Dd77sfr2002");
|
||||||
|
|
||||||
|
function register($mail, $promo, $pass)
|
||||||
|
{
|
||||||
|
$request = "INSERT INTO AIIDE_INSCRIPTIONS VALUES(?, ?, ?);";
|
||||||
|
$pdo = $dbh->prepare($request);
|
||||||
|
$pdo->execute(array($mail, $promo, $pass));
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate_register($mail, $login)
|
||||||
|
{
|
||||||
|
$request = "SELECT * FROM AIIDE_INSCRIPTIONS WHERE MAIL=?";
|
||||||
|
$pdo = $dbh->prepare($request);
|
||||||
|
$pdo->execute(array($mail));
|
||||||
|
|
||||||
|
$user = $pdo->fetch();
|
||||||
|
if($user)
|
||||||
|
{
|
||||||
|
include_once "roles.php";
|
||||||
|
$request_insert = "INSERT INTO AIIDE_USERS VALUES(?, ?, ?, ?, ?)";
|
||||||
|
$request_delete = "DELETE FROM AIIDE_INSCRIPTIONS WHERE MAIL=?";
|
||||||
|
|
||||||
|
$insert = $dbh->prepare($request_insert);
|
||||||
|
$insert->execute(array($user->MAIL, $user->LOGIN, $user->PROMO, $roles["std"], $user->PASSWD));
|
||||||
|
|
||||||
|
$delete = $dbh->prepare($request_delete);
|
||||||
|
$delete->execute(array($user->mail));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A compléter
|
||||||
|
function reject_register($mail)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
9
php/utilities/roles.php
Normal file
9
php/utilities/roles.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$roles = array(
|
||||||
|
"std" => 0,
|
||||||
|
"modo" => 1,
|
||||||
|
"admin" => 2
|
||||||
|
);
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in New Issue
Block a user