diff --git a/js/register.js b/js/register.js index e69de29..255332b 100644 --- a/js/register.js +++ b/js/register.js @@ -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"; + }); +}); \ No newline at end of file diff --git a/php/auth/login.php b/php/auth/login.php index dce4c92..51cf695 100644 --- a/php/auth/login.php +++ b/php/auth/login.php @@ -42,6 +42,6 @@ - Pas de compte ? Inscrivez-vous ! + Pas de compte ? Inscrivez-vous ! diff --git a/php/auth/register.php b/php/auth/register.php index 2a0f098..8020349 100644 --- a/php/auth/register.php +++ b/php/auth/register.php @@ -12,17 +12,26 @@ if($mail) { - $pass = filter_input(INPUT_POST, 'passwd', FILTER_SANITIZE_STRING); + $promo = filter_input(INPUT_POST, 'promo', FILTER_VALIDATE_INT | FILTER_SANITIZE_NUMBER_INT); - // A continuer + 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"; ?>
- - + + + + " /> diff --git a/php/utilities/functions.php b/php/utilities/functions.php new file mode 100644 index 0000000..c9b64fd --- /dev/null +++ b/php/utilities/functions.php @@ -0,0 +1,39 @@ +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) +{ + +} + +?> \ No newline at end of file diff --git a/php/utilities/roles.php b/php/utilities/roles.php new file mode 100644 index 0000000..43086a5 --- /dev/null +++ b/php/utilities/roles.php @@ -0,0 +1,9 @@ + 0, + "modo" => 1, + "admin" => 2 +); + +?> \ No newline at end of file