Guest User

Untitled

a guest
Feb 7th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. <?php
  2.  
  3. if (!empty($_POST)) {
  4.  
  5. if(isset($name)){
  6.  
  7. if(isset($pass)){
  8.  
  9. if($pass !== 0 && $name !== 0){
  10.  
  11. include "conexion.php";
  12.  
  13. $sql = "SELECT * FROM user WHERE username == :name OR email == :name AND password == :pass";
  14.  
  15. $query = $con -> prepare($sql);
  16.  
  17. $query->bindParam(':name', $name);
  18. $query->bindParam(':pass', $pass);
  19. $query->execute();
  20.  
  21. $contador = $query -> rowCount();
  22.  
  23. while ($r = $query->fetch_array()) {
  24.  
  25. $user_id = $r["id"];
  26. $user_rank = $r["CONF"];
  27. break;
  28.  
  29. }
  30.  
  31. if ($user_id == null && $user_rank == null) {
  32.  
  33. print "<script>alert("Acceso invalido.");window.location='../login';</script>";
  34.  
  35. } else {
  36.  
  37. session_start();
  38. $_SESSION["user_id"] = $user_id;
  39. $_SESSION["rank"] = $user_rank;
  40. print "<script>window.location='../home.php';</script>";
  41.  
  42. }
  43.  
  44. } else {
  45.  
  46. echo "<script>alert("Valores no aceptados"); window.location='../login';</script>";
  47.  
  48. }
  49.  
  50. } else {
  51.  
  52. echo "<script>alert("No escribiste la contraseña"); window.location='../login';</script>";
  53.  
  54. }
  55.  
  56. } else {
  57.  
  58. echo "<script>alert("No escribiste el usuario"); window.location='../login';</script>";
  59.  
  60. }
  61.  
  62. } else {
  63.  
  64. echo "<script>alert("No escribiste nada"); window.location='../login';</script>";
  65.  
  66. }
Add Comment
Please, Sign In to add comment