Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/01/2013, 08:56
daicrel
 
Fecha de Ingreso: enero-2013
Mensajes: 36
Antigüedad: 11 años, 3 meses
Puntos: 0
Como cerrar sesion

Hola buenas como estan otra vez yo. Necesito de nuevo un favor tengo un programa en el hay q ingresar por medio de usuarios, debo colocarle seguridad ya lo hice pero ajuro debe dar cerrar sesion, abra otro modo de hacer?, y como hago para restringir el acceso por usuarios diferentes.

verifica.php
Código PHP:
Ver original
  1. <?php
  2. include("conexion.php");
  3.  
  4.  
  5.  
  6.  
  7.  
  8. $resp = pg_query("select * from empleados where usuario='".$_POST['usuario']."' AND clave='".$_POST['clave']."' ");
  9. $sql = pg_fetch_array($resp);
  10.  
  11. $nombre=$_POST['usuario'];
  12.  
  13. if(($_POST['clave'] != $sql['clave']) or ($_POST['usuario'] != $sql['usuario']) ) {
  14.    
  15. echo "<html>
  16.  
  17. <strong><span style=\"color: red\">Datos Incorrectos... </span></strong>
  18.  
  19. </html>";
  20.  
  21.  
  22. header("Refresh: 1; URL=Ingresar.php");
  23.    
  24. }
  25.  
  26. if($sql['tipo_usuario']=='usuario'){
  27.     session_start();
  28.     $_SESSION["autenticado"]= "SI";
  29.     header("Refresh: 1; URL=Permisos.php");
  30.     echo "<html>
  31.  
  32. <div border solid 1 px>
  33.  
  34. <strong>Hola $nombre! Bienvenido al Sistema</strong>
  35. </div>
  36.  
  37. </html>";
  38. }else if ($sql['tipo_usuario']=='coordinador') {
  39.     session_start();
  40.     $_SESSION["autenticado"]= "SI";
  41.     header("Refresh: 1; URL=menuCoordinador.php");
  42.     echo "<html>
  43.  
  44. <div border solid 1 px>
  45.  
  46. <strong>Hola $nombre! Bienvenido al Sistema</strong>
  47. </div>
  48.  
  49. </html>";
  50. }else if($sql['tipo_usuario']=='gerente'){
  51.     session_start();
  52.     $_SESSION["autenticado"]= "SI";
  53.     header("Refresh: 1; URL=menuGerente.php");
  54.     echo "<html>
  55.  
  56. <div border solid 1 px>
  57.  
  58. <strong>Hola $nombre! Bienvenido al Sistema</strong>
  59. </div>
  60.  
  61. </html>";
  62. }else if($sql['tipo_usuario']=='rrhh'){
  63.     session_start();
  64.     $_SESSION["autenticado"]= "SI";
  65.     header("Refresh: 1; URL=reportes/reportePermisos.php");
  66.     echo "<html>
  67.  
  68. <div border solid 1 px>
  69.  
  70. <strong>Hola $nombre! Bienvenido al Sistema</strong>
  71. </div>
  72.  
  73. </html>";
  74. } else if($sql['tipo_usuario']=='administracion'){
  75.     session_start();
  76.     $_SESSION["autenticado"]= "SI";
  77.     header("Refresh: 1; URL=reportes/reporteAlimentos.php");
  78.     echo "<html>
  79.  
  80. <div border solid 1 px>
  81.  
  82. <strong>Hola $nombre! Bienvenido al Sistema</strong>
  83. </div>
  84.  
  85. </html>";
  86. }else {
  87.     header("Refresh: 1; URL=Ingresar.php");
  88.    
  89.     echo "<html>
  90.  
  91. <div border solid 1 px>
  92.  
  93. <strong>Acesso Denegado. Intente nuevamente</strong>
  94.  
  95. </div>
  96.  
  97. </html>";
  98. };
  99.  
  100.    
  101. ?>

Aprobacion.php

Código PHP:
Ver original
  1. <?php
  2. include("seguridad.php");
  3. ?>
  4. <html>
  5.  
  6. <head>
  7.     <meta http-equiv="content-type" content="text/html; charset=UTF-8">  
  8.     <title>INDER/SSPA/APROBACION DE SOLICITUDES DE PERMISOS</title>
  9.     <link href="css/estilo_aprobacion.css" rel="stylesheet" />
  10. </head>
  11.  
  12. <body>
  13.  
  14.     <br><br><br><br>
  15.    
  16.     <div id='contenedor'>  
  17.        
  18.     <div id="logo"><img id="img" src="img/cintillo_inst.jpg">
  19.     </div>
  20.            
  21.     <div id="nombre"><h3>Sistema de Solicitud de Permisos y Alimentos</h3>
  22.    
  23.     <p><strong><h5>APROBACI&Oacute;N DE SOLICITUDES DE PERMISOS</h5></strong></p>
  24.     </div>
  25.                
  26.     <div id="lista">
  27.  
  28.    
  29.    </div>
  30.    
  31.    <div id="pie"><img id="img2" src="img/pie_pag1.png">
  32.         </div>
  33.     <a href="salir.php" style="color:#000000"><strong>Cerrar sesi&oacute;n</strong></a>
  34.     </div>
  35.                        
  36. </body>
  37. </html>

seguridad.php

Código PHP:
Ver original
  1. <?
  2. //Inicio la sesión
  3. //COMPRUEBA QUE EL USUARIO ESTA AUTENTICADO
  4. if ($_SESSION["autenticado"] != "SI") {
  5. //si no existe, va a la página de autenticacion
  6. header("Location:Ingresar.php");
  7. //salimos de este script
  8. exit();
  9. }
  10. ?>

salir.php

Código PHP:
Ver original
  1. <?php
  2. ?>
  3.  
  4. <html>
  5. <head>
  6.     <title>INDER/SSPA/Contenido no seguro</title>
  7.     <link href="css/estiloSalir.css" rel="stylesheet" />
  8. </head>
  9.  
  10. <body>  <br><br><br><br><br><br><br><br>
  11.         <div align="center" id="salir">
  12.         <strong>Ahora est&aacute;s fuera de la aplicaci&oacute;n segura.</strong>
  13.         <br>
  14.         <br>
  15.         <div><img id="img" src="img/candado.gif"></div>
  16.         <br>
  17.         <a href="Ingresar.php" style="color:#000000"><strong>Autenticar usuario</strong></a>
  18.         </div>
  19. </body>
  20. </html>