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 54 55 56 57 58 59 60 61
|
<?php
class Identification
{
private $login;
private $password;
private $mail;
private $cat;
public function resultat($mail, $pass)
{
$this->mail = strip_tags($mail);
$this->password = strip_tags($pass);
if($this->testInfos($this->mail, $this->password) == true)
{
$_SESSION['acces_visiteur']= "oui";
$_SESSION['login'] = $this->login;
$_SESSION['mail'] = $this->mail;
$_SESSION['cat'] = $this->cat;
$message_erreur = "Identification OK";
}
else
{
$message_erreur = "L'identification a échouée";
}
}
private function emailValide($mail)
{
return preg_match("#^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$#", $mail);
}
private function testInfos($login, $password)
{
$bool = true;
if($this->emailValide($login)== true)
{
$req = $bdd->query('SELECT * FROM comptes_utilisateurs WHERE Adresse_Email = '.$login.'';
while($data = $req>fetch()){
{
if(md5($password) == $data->Mot_de_Passe)
{
$bool = true;
$this->login = $data->Nom_Utilisateur;
$this->cat = $data->Categorie;
}
}
$req->closeCursor();
}
return $bool;
}
} |