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<?php
include("conexion.php");
$resp = pg_query("select * from empleados where usuario='".$_POST['usuario']."' AND clave='".$_POST['clave']."' ");
$nombre=$_POST['usuario'];
if(($_POST['clave'] != $sql['clave']) or ($_POST['usuario'] != $sql['usuario']) ) {
echo "<html>
<strong><span style=\"color: red\">Datos Incorrectos... </span></strong>
</html>";
header("Refresh: 1; URL=Ingresar.php");
}
if($sql['tipo_usuario']=='usuario'){
$_SESSION["autenticado"]= "SI";
header("Refresh: 1; URL=Permisos.php"); echo "<html>
<div border solid 1 px>
<strong>Hola $nombre! Bienvenido al Sistema</strong>
</div>
</html>";
}else if ($sql['tipo_usuario']=='coordinador') {
$_SESSION["autenticado"]= "SI";
header("Refresh: 1; URL=menuCoordinador.php"); echo "<html>
<div border solid 1 px>
<strong>Hola $nombre! Bienvenido al Sistema</strong>
</div>
</html>";
}else if($sql['tipo_usuario']=='gerente'){
$_SESSION["autenticado"]= "SI";
header("Refresh: 1; URL=menuGerente.php"); echo "<html>
<div border solid 1 px>
<strong>Hola $nombre! Bienvenido al Sistema</strong>
</div>
</html>";
}else if($sql['tipo_usuario']=='rrhh'){
$_SESSION["autenticado"]= "SI";
header("Refresh: 1; URL=reportes/reportePermisos.php"); echo "<html>
<div border solid 1 px>
<strong>Hola $nombre! Bienvenido al Sistema</strong>
</div>
</html>";
} else if($sql['tipo_usuario']=='administracion'){
$_SESSION["autenticado"]= "SI";
header("Refresh: 1; URL=reportes/reporteAlimentos.php"); echo "<html>
<div border solid 1 px>
<strong>Hola $nombre! Bienvenido al Sistema</strong>
</div>
</html>";
}else {
header("Refresh: 1; URL=Ingresar.php");
echo "<html>
<div border solid 1 px>
<strong>Acesso Denegado. Intente nuevamente</strong>
</div>
</html>";
};
?>
Aprobacion.php
Código PHP:
Ver original<?php
include("seguridad.php");
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>INDER/SSPA/APROBACION DE SOLICITUDES DE PERMISOS</title>
<link href="css/estilo_aprobacion.css" rel="stylesheet" />
</head>
<body>
<br><br><br><br>
<div id='contenedor'>
<div id="logo"><img id="img" src="img/cintillo_inst.jpg">
</div>
<div id="nombre"><h3>Sistema de Solicitud de Permisos y Alimentos</h3>
<p><strong><h5>APROBACIÓN DE SOLICITUDES DE PERMISOS</h5></strong></p>
</div>
<div id="lista">
</div>
<div id="pie"><img id="img2" src="img/pie_pag1.png">
</div>
<a href="salir.php" style="color:#000000"><strong>Cerrar sesión</strong></a>
</div>
</body>
</html>
seguridad.php
Código PHP:
Ver original<?
//Inicio la sesión
//COMPRUEBA QUE EL USUARIO ESTA AUTENTICADO
if ($_SESSION["autenticado"] != "SI") {
//si no existe, va a la página de autenticacion
header("Location:Ingresar.php"); //salimos de este script
}
?>
salir.php
Código PHP:
Ver original<?php
?>
<html>
<head>
<title>INDER/SSPA/Contenido no seguro</title>
<link href="css/estiloSalir.css" rel="stylesheet" />
</head>
<body> <br><br><br><br><br><br><br><br>
<div align="center" id="salir">
<strong>Ahora estás fuera de la aplicación segura.</strong>
<br>
<br>
<div><img id="img" src="img/candado.gif"></div>
<br>
<a href="Ingresar.php" style="color:#000000"><strong>Autenticar usuario</strong></a>
</div>
</body>
</html>