aca les dejo el codigo haber si entienden algo:
index.php
Código PHP:
<?
session_start();
$error=$_GET["error"];
$login=$_GET["login"];
$password=$_GET["password"];
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif;color: #003399; font-size: 12px;}
.style2 {font-family: Arial, Helvetica, sans-serif;color: #003399;font-size: 24px;font-weight: bold;}
.style3 {font-family: Arial, Helvetica, sans-serif;color: #000000; font-size: 12px;}
-->
</style>
</head>
<body alink="#003399" vlink="#003399">
<table width="800" height="600" border="0" cellspacing="0">
<tr>
<td> <?
if ($error=="cero"){?>
<script language="JavaScript" type="text/JavaScript">
alert ("Login y Password Invalidos")
</script> <meta http-equiv="refresh">
<?php }
?></td>
</tr>
<tr>
<td><form action="validar_inicio.php" method="post" name="Form" >
<table width="100%" height="100%" border="0">
<tr>
<td width="100%" >
<div align="center">
<p>Login :<br>
<input type="login" name="login">
<br>
Password :<br>
<strong><strong>
<input type="password" name="password">
</strong></strong> <br>
<br>
<input type="Submit" name="enviar" value="Entrar" >
</p>
</div></td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
</html>
validar_acceso.php
Código PHP:
<?
//Declaracion y optencion de vaiables
$login=$_POST['login'];
$password=$_POST['password'];
include("Conectarse.php");
$conn=Conectarse();
$query="SELECT * FROM usuario where login= '$login' and password= '$password'";
$result=pg_Exec($conn,$query);
while($row=pg_fetch_array($result))
$tipo = $row['tipo'];
if ($tipo!="") {
session_start();
session_register("user");
$user=$tipo;
session_register("name");
$name=$login;
header("location:home.php");
}
else{
header("location:control_acceso.php?error=cero");
}
?>
home.php
Código PHP:
<?
session_start();
if (session_is_registered(user)){
if ($user==""){header("location:index.php");}
else{
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="200" border="0">
<tr>
<td> <?
if ($error=="cero"){?>
<script language="JavaScript" type="text/JavaScript">
<!--
alert ("Login y Password Invalidos")
//-->
</script> <meta http-equiv="refresh">
<?php }
?></td>
</tr>
<tr>
<td>hola</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
<?
}
}
else{
header("location:control_acceso.php?error=cero");
}
?>