<?php

    include ("../connect-bdd/connexion_bdd.php");

    // on teste si nos variables sont d�finies
    if (isset($_POST['pseudo_user']) AND isset($_POST['mot_de_passe']) /*& $_POST['mot_de_passe'] === "Noumba06"*/)
    {
        $reponse = $bdd->query("SELECT * FROM `admin`") or die(print_r($bdd->errorInfo()));

        while ($donnees = $reponse->fetch()) {
            if ($_POST['pseudo_user'] == $donnees['login']
                && ($sha256=hash("sha256","ghgzeryhsd2fhdhuy" . $_POST['mot_de_passe'] . "vdqSF564g456xyydsq")) === $donnees['pwd'])
            {
                $id = $donnees['id'];
                $page_en_cours = "accueil";
                header("Location: ../templates/layout-admin.php?id=" . $id . "&pageVisitee=" . $page_en_cours);
            }
        }

        $reponse->closeCursor();
    }
?>
