Guest User

Untitled

a guest
Jan 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_POST["enviar"])){
  4.  
  5. $usuario_entrar=$_POST["usuario_entrar"];
  6. $contrasenha_entrar=$_POST["contrasenha_entrar"];
  7.  
  8. if(empty($usuario_entrar) || empty($contrasenha_entrar)){
  9.  
  10. echo("ERRO. Debes introducir un nome de usuario e un contrasinal correctos. <br />");
  11.  
  12. }else{
  13.  
  14. require_once("conexion_bd.php");
  15.  
  16. try{
  17.  
  18. $resultado_entrar=$mysqli->stmt_init();
  19. $resultado_entrar->prepare("SELECT usuario, contrasenha FROM datos_personales WHERE usuario=? AND contrasenha=?");
  20. $resultado_entrar->bind_param("ss",$usuario_entrar,$contrasenha_entrar);
  21. $resultado_entrar->execute();
  22. $resultado_entrar->bind_result($usuario_entrar,$contrasenha_entrar);
  23.  
  24. $fila=$resultado_entrar->fetch_rows();
  25.  
  26. if($fila!=null){
  27.  
  28. session_start();
  29. $_SESSION["usuario_entrar"]=$usuario_entrar;
  30. //header("Location: contenido.php");
  31. echo("Correcto!");
  32.  
  33. }else{
  34.  
  35. echo("ERRO. Usuario ou contrasinal non válidos. <br />");
  36.  
  37. }
  38.  
  39. }catch(Exception $mysqli_ex2){
  40.  
  41. die("Produciuse o seguinte erro: " . "<br />" . $mysqli_ex2->getMessage() . "<br />" . $mysqli_ex2->getCode() . "<br />");
  42.  
  43. }
  44. }
  45. }
  46. ?>
Add Comment
Please, Sign In to add comment