Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <?php
  2. class users
  3. {
  4. public $login;
  5. public $password;
  6. public $r_password;
  7. public $email;
  8. private $host='localhost';
  9. private $user='root';
  10. private $password1='';
  11. private $db;
  12. private $dbName='Univers';
  13.  
  14. function __construct($login="",$password="",$r_password="",$email="")
  15. {
  16. $this->login = $login;
  17. $this->password = $password;
  18. $this->r_password = $r_password;
  19. $this->email = $email;
  20. $this->db = new PDO("mysql:host=$this->host;dbname=$this->dbName", $this->user, $this->password1);
  21.  
  22. }
  23.  
  24. function checklogin()
  25. {
  26. $res = $this->db->query("SELECT email FROM users WHERE email = '$this->email'");
  27. $l_records = $res->fetch(PDO::FETCH_ASSOC);
  28. if ($l_records)
  29. {
  30. echo "email занят!";
  31. }
  32.  
  33. }
  34. function checkpass()
  35. {
  36. $res1 = $this->db->query("SELECT login FROM users WHERE login = '$this->login'");
  37. $l_records1 = $res1->fetch(PDO::FETCH_BOUND);
  38. if ($l_records1)
  39. {
  40. echo "login занят!";
  41. }
  42. }
  43.  
  44. function inputdb()
  45. {
  46. if($this->r_password == $this->password)
  47. {
  48. $hash = password_hash($this->password, PASSWORD_DEFAULT);
  49.  
  50. }
  51. $stmt = $this->db->prepare('INSERT INTO users (login,hash,email) VALUES (:login,:hash,:email)');
  52. $stmt->bindParam(':login', $login);
  53. $stmt->bindParam(':hash', $hash);
  54. $stmt->bindParam(':email', $email);
  55. $stmt->execute();
  56. $db = Null;
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement