Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5. include("conexion/conexion.php");
  6.  
  7.  
  8. $user = $_POST['user'];
  9. $password = $_POST['password'];
  10.  
  11.  
  12. $user_check = $DB_con->prepare('SELECT user FROM user WHERE user = :user LIMIT 1');
  13. $user_check->bindParam(':user', $_POST['user']);
  14. $user_check->execute();
  15. if($user_check->rowCount() > 0){ ?>
  16.  
  17.  
  18. <div class='col s12 card-panel blue lighten-2 center'>
  19. <h5 class='black-text text-darken-2 center CONDENSED LIGHT5'>¡ Ups Aviso: Usuario Incorrecto !
  20. </h5>
  21. <?php header("refresh:5;login.php"); ?>
  22. </div>
  23.  
  24.  
  25.  
  26. <?php
  27.  
  28. }
  29.  
  30. $hash_password= hash('sha256', $_POST['password']);
  31. $sql = $DB_con->prepare('SELECT * FROM user WHERE user = :user AND
  32. password = :password AND idnivel = 'Administrador' LIMIT 1');
  33. $sql->bindParam(':user', $_POST['user']);
  34. $sql->bindParam(':password', $_POST['password']);
  35. $sql->execute();
  36. $sql->closeCursor();
  37. if($sql->rowCount()){
  38.  
  39.  
  40. session_start();
  41.  
  42.  
  43. $_SESSION['id'] = $id;
  44. $_SESSION['correo'] = $correo;
  45. $_SESSION['idnivel'] = 'Administrador';
  46. $_SESSION['Administrador'] = $clave;
  47. $_SESSION['nombres'] = $row['nombres'] . ' ' . $row['apellidos'];
  48.  
  49.  
  50. ?>
  51.  
  52.  
  53. <?php header("Location: admin/home.php"); ?>
  54.  
  55.  
  56. <?php } else { ?>
  57.  
  58.  
  59. <div class='col s12 card-panel blue lighten-2 center'>
  60. <h5 class='black-text text-darken-2 center CONDENSED LIGHT5'>¡ Ups Aviso: Contraseña incorrecta !
  61. </h5>
  62. <?php header("refresh:5;login.php"); ?>
  63. </div>
  64.  
  65.  
  66.  
  67. <?php
  68.  
  69.  
  70. }
  71.  
  72. $hash_password= hash('sha256', $_POST['password']);
  73. $sql = $DB_con->prepare('SELECT * FROM user WHERE user = :user AND
  74. password = :password AND idnivel = 'Usuarios' LIMIT 1');
  75. $sql->execute();
  76. $sql->closeCursor();
  77. if($sql->rowCount()){
  78.  
  79.  
  80. session_start();
  81.  
  82.  
  83. $_SESSION['id'] = $id;
  84. $_SESSION['correo'] = $correo; //muestra el login
  85. $_SESSION['idnivel'] = 'Secretarias'; //muestra el nivel del usuario
  86. $_SESSION['Secretarias'] = $correo;
  87. $_SESSION['nombres'] = $row['nombres'] . ' ' . $row['apellidos'];
  88. $_SESSION['cedula'] = $row['cedula'];
  89.  
  90.  
  91. ?>
  92.  
  93.  
  94. <?php header("Location: secretaria/home.php"); ?>
  95.  
  96.  
  97. <?php } else { ?>
  98.  
  99.  
  100. <div class='col s12 card-panel blue lighten-2 center'>
  101. <h5 class='black-text text-darken-2 center CONDENSED LIGHT5'>¡ Ups Aviso: Contraseña incorrecta !
  102. </h5>
  103. <?php header("refresh:5;login.php"); ?>
  104. </div>
  105.  
  106.  
  107. <?php
  108.  
  109. }
  110.  
  111. $hash_password= hash('sha256', $_POST['password']);
  112. $sql = $DB_con->prepare('SELECT * FROM user WHERE user = :user AND
  113. password = :password AND idnivel = 'Secretarias' LIMIT 1');
  114. $sql->execute();
  115. if($sql->rowCount()){
  116.  
  117.  
  118. session_start();
  119.  
  120.  
  121. $_SESSION['id'] = $id;
  122. $_SESSION['correo'] = $correo;
  123. $_SESSION['idnivel'] = 'Usuarios';
  124. $_SESSION['Usuarios'] = $correo;
  125. $_SESSION['nombre'] = $row['nombre'] . ' ' . $row['apellido'];
  126.  
  127. ?>
  128.  
  129.  
  130. <?php header("Location: usuarios/home.php"); ?>
  131.  
  132.  
  133. <?php } else { ?>
  134.  
  135.  
  136. <div class='col s12 card-panel blue lighten-2 center'>
  137. <h5 class='black-text text-darken-2 center CONDENSED LIGHT5'>¡ Ups Aviso: Contraseña incorrecta !
  138. </h5>
  139. <?php header("refresh:5;login.php"); ?>
  140. </div>
  141.  
  142.  
  143. <?php
  144. }
  145.  
  146. $sql = null;
  147. $DB_con = null;
  148.  
  149. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement