Guest User

Untitled

a guest
Dec 11th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. <?php
  2. class Membre{
  3.  
  4. protected $db;
  5.  
  6. protected $id;
  7. protected $login;
  8. protected $password;
  9. protected $email;
  10.  
  11. public function __construct(){
  12. try {
  13. $this->db = new PDO('mysql:dbname=test;host=localhost', 'root', '');
  14. } catch (PDOException $e) {
  15. echo 'Erreur de connexion : ' . $e->getMessage();
  16. }
  17. }
  18.  
  19. public function setLogin($str){
  20. $this->login = $str;
  21. }
  22.  
  23. public function setPassword($str){
  24. $this->password = $str;
  25. }
  26.  
  27. public function setEmail($str){
  28. $this->email = $str;
  29. }
  30.  
  31. public function create(){
  32. $req = $this->db->prepare('INSERT INTO users(login, password, email) VALUES(:login, :password, :email)');
  33. $req->execute(array(
  34. 'login' => $this->login,
  35. 'password' => $this->password,
  36. 'email' => $this->email
  37. ));
  38.  
  39. echo 'Le membres est bien ajouté';
  40. }
  41.  
  42. }
  43. ?>
Add Comment
Please, Sign In to add comment