<?	
	session_start();


	$Login = $_POST['usuario'];
	$Acceso = $_POST['pass'];
		
	include_once('./includes/Conexion.inc.php');

	Conectar();
	$sql = "Select Id, Mail, Pass, Nombre, Apellido, Categoria from Usuarios where Mail = '$Login'";
  	$res = mysql_query($sql);
	if (mysql_num_rows($res)==0) {
 		Desconectar();
		header("Location: index.php?error=3");
		exit;
	}
	list($Id,$Mail,$Pass, $Nombre, $Apellidos, $Categoria) = mysql_fetch_row($res);
	if ($Pass != $Acceso) {
		Desconectar();
		header("Location: index.php?error=1");
		exit;
	}else{
		if ($Categoria == 1){
			$_SESSION['id_admin']=$Id;
			$_SESSION['gestor']=$Id;
			$_SESSION['repor']=$Id;	
			}
		if ($Categoria == 3)
			$_SESSION['gestor']=$Id;
		if ($Categoria == 2)
			$_SESSION['repor']=$Id;	
		$_SESSION['nombre']="$Nombre $Apellidos";	
		$_SESSION['id_usuario']=$Id;		
	}

	Desconectar();
	header("Location: ./index.php");

?>

