authentification d'un compte en PHP
Bonjour,
j'ai un soucie avec mon code php.
je m'explique : j'ai une table client qui contient 2 données
id : 1 nom : xxx
id : 2 nom : yyy
lors de l'authentification si je fais rentrer xxx ====> sa marche
mais yyy =====> sa me renvoie mon dernier ECHO
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| <?php
session_start();
$loginOK = false; // cf Astuce
//connection a la base de données
try
{
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO('mysql:host=localhost;dbname=test', 'root', '', $pdo_options);
// Insertion du message à l'aide d'une requête préparée
$reponse = $bdd->query('SELECT nom FROM client ');
$donnees = $reponse->fetch(PDO::FETCH_ASSOC);
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
if ( isset($_POST) && (!empty($_POST['Utilisateur'])))
{
// On vérifie que son login et mdp sont corrects
if ($_POST['Utilisateur'] == $donnees['nom'] )
{
$loginOK = true;
}
if ($loginOK)
{
$_SESSION['nom'] = $donnees['nom'];
sleep(2);
header ('location: main.php');
}
else
{
echo ' Une erreur est survenue, veuillez réessayer !';
echo ' cliquez "<a href="index.php"><strong>ICI</strong></a>" pour revenir a la page d\'authentification';
}
}
?> |