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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
class Membre {//classe qui permet d'enregister les infos de chaque membres
//private $bdd; //=>je ne dois pas le mettre
private $id_membre; //permet de rechercher les relions en fonction des tables
private $email;
private $membre_exist = NULL;
public function __construct() {
// ne pas le mettre $this->bdd = bdd::getIntance();
}
public function getMembreExist()
{
return $this->membre_exist;
}
public function isMembreExist($email, $pass) {//vérifi s'il existe
$this->email = $email;
$this->pass = $pass;
$bdd = bdd::getIntance();
$query = 'SELECT * FROM membre WHERE pass=:pass';
$prep = $bdd->prepare($query);
$prep->bindValue(':pass', $passs, PDO::PARAM_STR);
$prep->execute();
$data = $prep->fetch();
//si le couple correspond , il faut forcer la modification du profil SU
if ($data['email'] == $email) {
$this->membre_exist = TRUE;
}
$_SESSION['membre'] = $this;// on crée la session membre
}
public function trouveIdentifiant($email, $password) {
$this->email = $email;
$bdd = Bdd::getIntance();
$query = 'SELECT * FROM membre WHERE email=:email';
$prep = $bdd->prepare($query);
$prep->bindValue(':email', $email, PDO::PARAM_STR);
$prep->execute();
$data = $prep->fetch(PDO::FETCH_OBJ);
if (!isset($data->email)) { //email inexistant = erreur 2
$this->erreur = 2; //informe à la classe que email est pas bon
} else {
if ($data->email == $email AND $data->pass == $password) {
echo $email . $password;
$this->id_membre_trouver = $data->id; //on tranmet le numéro id
$this->erreur = 0; //connexion ok
$this->verifModifAdmin($this->id_membre_trouver, $email);
} else {
$this->erreur = 1; //pass non valide
}
}
}
public function allAtribut() {//récupérer tout les attributs
return get_object_vars($this);
}
public function trouveMembre($id_membre) {
echo "recheche du membre<br/>";
$bdd = Bdd::getIntance();
$query = 'SELECT M.*,A.permis
FROM membre M
JOIN auth_membre A
ON M.id = A.id_membre
WHERE M.id = 1
';
$prep = $bdd->prepare($query);
$prep->bindValue(':id_membre', $id_membre, PDO::PARAM_STR);
$prep->execute();
$data = $prep->fetch(PDO::FETCH_OBJ);
print_r($data);
/*
$this->id_membre = $data->id;
$this->email = $data->email;
$this->civilite = $data->civilite;
$this->nom = $data->nom;
$this->prenom = $data->prenom;
$this->telephone = $data->telephone;
$this->addresse = $data->adresse;
$this->suspendu = $data->suspendu;
* */
}
public function getIdMembre() {
return $this->id_membre;
}
public function getEmail() {
return $this->email;
}
public function getCivilite() {
return $this->civilite;
}
public function getNom() {
return $this->nom;
}
public function getPrenom() {
return $this->prenom;
}
public function getAdresse() {
return $this->adresse;
}
public function getTelephone() {
return $this->telephone;
}
} |
Partager