Advertisement
Guest User

9

a guest
Oct 10th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. public function login($user, $pass) {
  2.  
  3. try {
  4.  
  5. $query = "SELECT * FROM `usuarios` WHERE `usuario` = :user AND `pass` = MD5(:pass) LIMIT 1";
  6.  
  7. $stmt = $this->_conn->prepare($query);
  8. $stmt->bindParam(':user', $user, PDO::PARAM_STR);
  9. $stmt->bindParam(':pass', $pass, PDO::PARAM_STR);
  10. $stmt_result = $stmt->execute();
  11.  
  12. if($stmt->rowCount() > 0) {
  13. $resultado_assoc = $stmt->fetch(PDO::FETCH_ASSOC);
  14. $_SESSION['uid'] = $resultado_assoc['usuarios_id'];
  15. $_SESSION['uname'] = $resultado_assoc['usuario'];
  16. $this->redireccion("index.php");
  17. } else {
  18. return false;
  19. }
  20.  
  21. }
  22. catch (PDOException $e){
  23. die("Error inesperado, contacte a la administracion.");
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement