Created
May 7, 2019 14:49
-
-
Save m-242/624d18a72bb766b9e452b8fb83bb987f to your computer and use it in GitHub Desktop.
Revisions
-
m-242 created this gist
May 7, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ <?php require_once(__DIR__ . '/../lib/functions_db.php'); require_once(__DIR__ . '/../lib/functions_input_sanatizing.php'); // Les fonctions utilisées function check_login(){ // récup des valeurs du formulaire $u = cleanInput($_POST["usr_mail"]); $conn = db_connect(); // Créer la requête de création $q = "SELECT pwd FROM users WHERE (mail = \"$u\" OR username = \"$u\")"; $r = $conn->query($q); $rr = $r->fetch_assoc(); $r->close(); db_disconnect($conn); if(password_verify($_POST["password"], $rr["pwd"])){ //Connection //récup des infos à mettre dans la session $conn = db_connect(); $q = "SELECT id, username, mail FROM users WHERE (mail = \"$u\" OR username = \"$u\")"; $r = $conn->query($q); $rr = $r->fetch_assoc(); $r->close(); db_disconnect($conn); // puis les mettre dedans session_start(); $_SESSION["id"] = $rr["id"]; $_SESSION["username"] = $rr["username"]; //$_SESSION["rank"] = $rr["rank"]; $_SESSION["mail"] == $rr["mail"]; } else { header("Location: ../login.php?retry=true"); exit; } echo 1; } // La page // pas de header, page pas vue par l'utilisateur check_login(); header("Location: ../index.php"); exit; ?>