Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2. include_once "../db_connection.php";
  3. $user = $_POST['user'];
  4. $pass = $_POST['pass'];
  5. $db = new DbConnect();
  6. $conn = $db->connect();
  7. $sql = 'SELECT * FROM "user" WHERE email = :email
  8. and pass = :pass';
  9. $sth = $conn->prepare($sql);
  10. $sth->bindParam(':email', $user);
  11. $sth->bindParam(':pass', md5($pass));
  12. $sth->execute();
  13. $userReturn = $sth->fetch();
  14.  
  15.  
  16. session_start();
  17. unset($_SESSION['erroUser']);
  18. unset($_SESSION['erroPass']);
  19. unset($_SESSION['erro']);
  20.  
  21. if ($userReturn) {
  22. unset($userReturn['pass']);
  23. $_SESSION['user'] = $userReturn;
  24. header("Location: /adm/home.php");
  25. } else {
  26. $_SESSION['count']++;
  27. if ($user != 'admin')
  28. $_SESSION['erroUser'] = "Usuário $user não existe";
  29. else
  30. $_SESSION['erroPass'] = "Senha inválida";
  31.  
  32. header("Location: /adm/index.php");
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement