Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
82
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 Login extends Conexao {
  4.  
  5. private $nome;
  6. private $email;
  7. private $telefome;
  8. private $senha;
  9.  
  10. public function setLogin($email){
  11. $this->email = $email;
  12. }
  13. public function setSenha($senha){
  14. $this->senha = $senha;
  15. }
  16. public function getEmail(){
  17. return $this->email;
  18. }
  19. public function getSenha(){
  20. return $this->senha;
  21. }
  22.  
  23.  
  24. public function Cadastro($email, $nome, $senha, $telefone)
  25. {
  26. $pdo = parent::getDB();
  27.  
  28. $cadastrar = $pdo->prepare("INSERT INTO usuarios(email, nome, senha, telefone) VALUES (:email, :nome, :senha, :telefone)");
  29. $cadastrar->bindParam("email", $email);
  30. $cadastrar->bindParam("nome", $nome);
  31. $cadastrar->bindParam("senha", $senha);
  32. $cadastrar->bindParam("telefone", $telefone);
  33. $cadastrar->execute();
  34. return $this->db->lastInsertId();
  35. }
  36.  
  37. public function logar(){
  38.  
  39. $pdo = parent::getDB();
  40.  
  41. $logar = $pdo->prepare("SELECT * FROM usuarios WHERE administrador_usuario = ? AND administrador_senha = ?");
  42. $logar->bindValue(1, $this->getEmail());
  43. $logar->bindValue(2, $this->getSenha());
  44. $logar->execute();
  45. if ($logar->rowCount() == 1):
  46. $dados = $logar->fetch(PDO::FETCH_OBJ);
  47. $_SESSION['administrador'] = $dados->administrador_nome;
  48. $_SESSION['logado'] = true;
  49. return true;
  50. else:
  51. return false;
  52. endif;
  53. }
  54.  
  55. public static function deslogar() {
  56. if(isset($_SESSION['logado'])):
  57. unset($_SESSION['logado']);
  58. session_destroy();
  59. header("Location: index.php");
  60. endif;
  61. }
  62. }
  63.  
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement