Advertisement
Sharloth

Untitled

Jul 20th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. public function Validar() {
  2.  
  3. //header('location:../php/inicio.php');
  4.  
  5. $consulta= $connect->query("SELECT username, password FROM usuario
  6. WHERE username = '".$this->usuario."' AND password = '".$this->clave ."' ");
  7. $consulta->setFetchMode(PDO::FETCH_ASSOC); //aqui se especifica el fetch mode a usar antes de ejecutar
  8. //$consulta->execute();
  9. $resultado = $consulta->fetch();
  10.  
  11. //******************** Si el usurio y clave son correctos **********************
  12.  
  13. if ($resultado['username'] == $this->usuario AND $resultado['password'] == $this->clave) {
  14. session_start();
  15. $_SESSION['nomusuario'] = $this->usuario;
  16. header('location:../php/verificar.php');
  17. }
  18.  
  19. //******************** Si el usurio y clave NO son correctos **********************
  20. else {
  21. $msg="Datos Incorrectos";
  22. echo "<script>alert('$msg')</script>";
  23. header('location:../index.php?error=datos_incorrectos');
  24.  
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement