Advertisement
Guest User

Untitled

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