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 47 48 49 50 51 52 53
|
<?php
try
{
$bdd = new PDO('mysql:host=localhost;dbname=asbl;charset=utf8', 'root', '');
}
catch(Exception $e)
{
// En cas d'erreur, on affiche un message et on arrête tout
die('Erreur : '.$e->getMessage());
}
if (isset($_POST['mail']) AND isset($_POST['pass']))
{
$mail = $_POST['mail'];
// Hachage du mot de passe
$pass_hache = sha1($_POST['pass']);
// Vérification des identifiants
$req = $bdd->prepare('SELECT id FROM membres WHERE email = :email AND pass = :pass');
$req->execute(array('email' => $mail, 'pass' => $pass_hache));
$resultat = $req->fetch();
if (!$resultat)
{
//Mauvais email ou mot de passe
header('Location: accueil.php?error=badIDPass');
}
else
{
$reponse = $bdd->prepare('SELECT membreASBL FROM membres WHERE email = :email AND pass = :pass');
$reponse->execute(array('email' => $mail, 'pass' => $pass_hache));
$donnees = $reponse->fetch();
if($result)
{
session_start();
$_SESSION['id'] = $resultat['id'];
//Connexion réussie
header('Location: espaceMembres.php?error=suceedCo');
}
else
{
header('Location: accueil.php?error=notASBL');
}
}
} |