示例#1
0
 public function login(UsersVO $user)
 {
     $this->email = $user->getEmail();
     $this->password = $user->getPassword();
     $sql = "SELECT * FROM `users` WHERE email=:email";
     $stmt = $this->db->conn->prepare($sql);
     $stmt->bindParam(':email', $this->email);
     $stmt->execute();
     $result = $stmt->fetch(PDO::FETCH_ASSOC);
     if ($stmt->rowCount() > 0 && password_verify($this->password, $result['password'])) {
         return $result['secret'];
     } else {
         return '<div data-alert class="alert-box alert radius">Login Failed.<a href="#" class="close">&times;</a></div>';
     }
 }
示例#2
0
 public function insert(UsersVO $user)
 {
     $username = $user->getUsername();
     $password = $user->getPassword();
     $sql = 'INSERT INTO users(username,password) VALUES (:username, :password)';
     $stmt = $this->db->conn->prepare($sql);
     $stmt->bindParam(':username', $username);
     $stmt->bindParam(':password', $password);
     $result = $stmt->execute();
     if ($result) {
         return true;
     } else {
         return false;
     }
 }