Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5.  
  6. ConsultarUsuario($_POST['inputUsuario'], $_POST['inputPassword']);
  7.  
  8. function ConsultarUsuario($usuario, $password)
  9. {
  10. require'conexion.php';
  11. $sentencia="SELECT * FROM usuarios WHERE usuario='".$usuario."' AND password='".$password."' ";
  12. $resultado=$conexion->query($sentencia) or die ("Error al comprobar usuario: ".mysqli_error($conexion));
  13.  
  14. $count = mysqli_num_rows($resultado); //Numero de filas del resultado de la consulta
  15.  
  16. if($count > 0) //si la variable count es mayor a 0
  17. {
  18. $_SESSION['usuario']=$usuario;
  19. echo '<script>';
  20. echo 'alert("Bienvenido!!");';
  21. echo 'window.location.href="menu.php";';
  22. echo '</script>';
  23. }
  24. else
  25. {
  26. echo '<script>';
  27. echo 'alert("Datos de acceso incorrectos");';
  28. echo 'window.location.href="admin.php";';
  29. echo '</script>';
  30. }
  31. }
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement