Ver Mensaje Individual
  #9 (permalink)  
Antiguo 22/02/2010, 10:21
Tenue
 
Fecha de Ingreso: febrero-2009
Mensajes: 24
Antigüedad: 15 años, 3 meses
Puntos: 0
Respuesta: Definir variable $_SESSION sin valor

Ese problema me pasa cuando quiero loguearme en index.php (el código está abajo), el cual llama al validar.php. Específicamente cuando los datos son correctos (porque tengo dos validaciones: una que valida si ha ingresado los datos en los dos input text, otro que valida si el usuario y contraseña son correctos, y el otro en donde todo está bien; ingresó los dos datos y sí existe en la base de datos).

Código del index.php:

Cita:
<?php
session_start();
if(empty($_SESSION["autentificado"])){
}else{
header("Location: bienvenido.php");
}
?>

<html>

<head>
<title>SAGEPAC - Sistema automatizado para la Gestión de Pagos de Contribuyentes</title>
<link rel="stylesheet" type="text/css" href="estilo.css" />
</head>

<body>
<div align="center">
<table border="0" width="1024" cellspacing="0" cellpadding="0">
<tr>

<?php include ("inc/arriba.php");?>

</tr>
<tr>
<td background="images/cuerpo.png" valign="top">
<div align="center">
<table border="0" width="967">
<tr>
<td valign="top">
<div align="center">
<table border="0" width="989" style="border-collapse: collapse" bordercolor="#669900">
<tr>
<td valign="top" width="100%">
<form action="validar.php" method="POST">
<p style="text-align: center">Por favor, ingrese sus datos de acceso:<br>
(Los datos con el asterisco (*) son obligatorios)</p>
<div align="center">
<table border="0" style="border-collapse: collapse" width="63%" bordercolor="#274B18">
<tr>
<td align="right" height="50">
<b>
Cédula (*):</b></td>
<td height="50" width="349">&nbsp;<input type="text" name="login"></td>
</tr>
<tr>
<td align="right" height="50">
<b>
Clave (*):</b></td>
<td height="50" width="349">&nbsp;<input type="password" name="password"></td>
</tr>
</table>
</div>
</div>
<div align="center">
<hr width="1%" size="1" color="#FFFFFF"></div>
<div align="center">
<input type="submit" value="Ingresar"> <input type="reset" value="Limpiar campos"></form>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<?php include ("inc/abajo.php");?>
</tr>
</table>
</div>

</body>

</html>
Código del validar.php:

Cita:
<html>

<head>
<title>SAGEPAC - Sistema automatizado para la Gestión de Pagos de Contribuyentes</title>
<link rel="stylesheet" type="text/css" href="estilo.css" />
</head>

<body>
<div align="center">
<table border="0" width="1024" cellspacing="0" cellpadding="0">
<tr>

<?php include ("inc/arriba.php");?>

</tr>
<tr>
<td background="images/cuerpo.png" valign="top">
<div align="center">
<table border="0" width="967">
<tr>
<td valign="top">
<div align="center">
<table border="0" width="989" style="border-collapse: collapse" bordercolor="#669900">
<tr>
<td valign="top" width="100%">
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="center"><?php
$link = mysql_connect("localhost", "root") or die ("Error en la Base de Datos");
$bd=mysql_select_db("sedematdb",$link) or die ("Verifique la Base de Datos");
$login=$_POST["login"];
$password=$_POST["password"];
if($login!="" and $password!="" and is_numeric($login))
{
$password=crypt($password, "semilla");
$query=mysql_query("SELECT login,password,nombre,apellido,correo FROM `usuarios` WHERE login='$login' && password='$password' ",$link);
if(mysql_num_rows($query)>0)
{
session_start();
$_SESSION["autentificado"]= "SI";
header('Location: bienvenido.php');
}
else
{
echo '<p align="center"><b>Ha sucedido el siguiente error:</b></p>' ;
echo '<p align="center">Usuario y/o contraseña incorrecta.</p>';
echo '<p align="center"><a href="/administrador/">Intentar de nuevo</a> | <a href="../">Volver a la Página principal</a></p><p></p>' ;
}
}
else
{
echo '<p align="center"><b>Ha sucedido el siguiente error:</b></p>' ;
echo '<p align="center">Debes ingresar todos los datos. Recuerda que el usuario es tu número de cédula.</p>';
echo '<p align="center"><a href="/administrador/">Intentar de nuevo</a> | <a href="../">Volver a la Página principal</a></p><p></p>' ;

}
?></p>
<p align="center">&nbsp;</p>
</form>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<?php include ("inc/abajo.php");?>
</tr>
</table>
</div>

</body>

</html>
Ya he cambiado todas las referencias a como me has indicado, lo hacía con http... porque me daba problemas. Aparentemente está trabajando bien. ¿Qué puedo hacer?

Saludos, y gracias.