Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class users
- {
- public $login;
- public $password;
- public $r_password;
- public $email;
- private $host='localhost';
- private $user='root';
- private $password1='';
- private $db;
- private $dbName='Univers';
- function __construct($login="",$password="",$r_password="",$email="")
- {
- $this->login = $login;
- $this->password = $password;
- $this->r_password = $r_password;
- $this->email = $email;
- $this->db = new PDO("mysql:host=$this->host;dbname=$this->dbName", $this->user, $this->password1);
- }
- function checkemail()
- {
- $res = $this->db->query("SELECT email FROM users WHERE email = '$this->email'");
- $l_records = $res->fetch(PDO::FETCH_ASSOC);
- if ($l_records)
- {
- echo "email занят!";
- }
- }
- function checklogin()
- {
- $res1 = $this->db->query("SELECT login FROM users WHERE login = '$this->login'");
- $l_records1 = $res1->fetch(PDO::FETCH_BOUND);
- if ($l_records1)
- {
- echo "login занят!";
- }
- }
- function inputdb()
- {
- if($this->r_password == $this->password)
- {
- $hash = password_hash($this->password, PASSWORD_DEFAULT);
- }
- $stmt = $this->db->prepare('INSERT INTO users (login,hash,email) VALUES (:login,:hash,:email)');
- $stmt->bindParam(':login', $login);
- $stmt->bindParam(':hash', $hash);
- $stmt->bindParam(':email', $email);
- $stmt->execute();
- $db = Null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement