Advertisement
Guest User

Untitled

a guest
Dec 18th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require_once '../Modelo/PDOConex.php';
  4.  
  5. if((!$nameUser = trim($_POST['user'])) || (!$password = md5(trim($_POST['pass']) ) ) ){
  6. header('location:../');
  7. }
  8.  
  9. try{
  10. $stmt = $db_con->prepare("SELECT
  11. idUsuarios,
  12. Cuenta,
  13. Contra
  14. FROM
  15. Usuarios
  16. WHERE
  17. Cuenta=:usuario");
  18.  
  19. $stmt->execute(array(":usuario"=>$nameUser));
  20. $fila = $stmt->fetch(PDO::FETCH_ASSOC);
  21.  
  22. if($fila['Contra']==$password){ //Credenciales correctas
  23.  
  24. require_once 'Log/getTipo.php';
  25.  
  26. switch (getTipo($fila['idUsuarios'], $db_con)){
  27.  
  28. case 'Administrativo':
  29. require_once 'Log/LoginAdmin.php';
  30. $_SESION['Usuario'] = serialize(logAdmin($fila['idUsuarios'], $db_con));
  31. $_SESION['Tipo']= 'Administrativo';
  32. break;
  33. case 'Docente':
  34. require_once 'Log/LoginDocente.php';
  35. $_SESION['Usuario'] = logDocente($fila['idUsuarios']);
  36. $_SESION['Tipo']= 'Docente';
  37. break;
  38. case 'Estudiante':
  39. require_once 'Log/LoginEstud.php';
  40. $_SESION['Usuario'] = logEst($fila['idUsuarios']);
  41. $_SESION['Tipo']= 'Estudiante';
  42. break;
  43. case 'Acudiente':
  44. require_once 'Log/LoginAcud.php';
  45. $_SESION['Usuario'] = logAcud($fila['idUsuarios']);
  46. $_SESION['Tipo']= 'Acudiente';
  47. break;
  48. default:
  49. echo "0";
  50. break;
  51. }
  52. }else{
  53. echo '0'; // Credenciales incorrectas
  54. }
  55. }catch(PDOException $e){
  56. echo $e->getMessage();
  57. }
  58. ?>
  59.  
  60. <?php
  61. require_once 'Controlador/Usuarios/Acudientes.php';
  62. require_once 'Controlador/Usuarios/Administrativos.php';
  63. require_once 'Controlador/Usuarios/Docentes.php';
  64. require_once 'Controlador/Usuarios/Estudiantes.php';
  65. session_start();
  66.  
  67. $_SESSION['Usuario'] = unserialize($_SESSION['Usuario'])
  68. if(isset($_SESSION['Usuario'])){
  69. header('location:Pages/login.php');
  70. }else{
  71.  
  72. switch($_SESSION['Tipo']){
  73. case 'Administrativo':
  74. if(count($_SESSION['Usuario']->getId_Colegio())>1){
  75. header('location:preAdmin.php');
  76. }else{
  77. header('location:indexAdmin.php');
  78. }
  79. break;
  80. case 'Docente':
  81. if(count($_SESSION['Usuario']->getId_Colegio())>1){
  82. header('location:preDocente.php');
  83. }else{
  84. header('location:indexDocente.php');
  85. }
  86. break;
  87. case 'Estudiante':
  88. header('location:indexEstudiante.php');
  89. break;
  90. case 'Acudiente':
  91. header('location:indexAcudiante.php');
  92. break;
  93. default:
  94. header('location:Controlador/logout.php');
  95. break;
  96. }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement