Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Membre{
- protected $db;
- protected $id;
- protected $login;
- protected $password;
- protected $email;
- public function __construct(){
- try {
- $this->db = new PDO('mysql:dbname=test;host=localhost', 'root', '');
- } catch (PDOException $e) {
- echo 'Erreur de connexion : ' . $e->getMessage();
- }
- }
- public function setLogin($str){
- $this->login = $str;
- }
- public function setPassword($str){
- $this->password = $str;
- }
- public function setEmail($str){
- $this->email = $str;
- }
- public function create(){
- $req = $this->db->prepare('INSERT INTO users(login, password, email) VALUES(:login, :password, :email)');
- $req->execute(array(
- 'login' => $this->login,
- 'password' => $this->password,
- 'email' => $this->email
- ));
- echo 'Le membres est bien ajouté';
- }
- }
- ?>
Add Comment
Please, Sign In to add comment