Hi to everybody:
I am very confused with this php problem:
I have 3 pages, everyone do that:
index.html:
form with two input text boxes. One for the user login and another for the password (type passwd).
login.php:
This page is executed when the user press the submit button of the index.html page so we have the
$user and $password visible from the login.php script.
The first thing that I do is check if the login and password are correct, in this case I use the
session_start() function and set up the $susuario to the $user value, this is acomplished doing
the follow:
session_register('susuario');
$susuario = $user;
well, after this, I use the header function to redirect the user to the frame.php (this is the
main page of my intranet)
frame.php:
On this page I do the follow as a first thing:
<?
session_start();
echo $susuario; exit(); // for test the problem
?>
continue with html code
The problem is that when I launch the browser. In spite of I introduce the correct
login-passwd, the session variable setuped correctly on login.php is not visible from the frame.php.
How is possible if I have setuped the $susuario on login.php????
The full code is this:
----------- index.html
..
<form action="login.php" method="get">
<table>
<tr>
<td><font face="Arial" size="1">login</font></td>
<td><input type="text" name="user" size="7" maxlength="7"></td>
</tr>
<tr>
<td><font face="Arial" size="1">passwd</font></td>
<td><input type="password" name="passwd" size="7" maxlength="7"></td>
<td><input type="submit" name="enviar" id="enviar" value="ok"></td>
</tr>
</table>
</form>
<br>
<a href="alta.php">Darme de alta</a><br>
..
---------- END index.html
---------- login.php
<?php
require 'funciones.php';
if ( Valida_Usuario($user,$passwd) ) { // <--- runs ok, returns 1 if I use my login and passwd
session_start();
Modifica_Visita($user);
session_register('susuario');
$susuario = $user;
header("Location: http://$HTTPHOST/$DOCROOT/frame.php");
exit();
}
else {
header("Location: http://$HTTPHOST/$DOCROOT/index.html");
exit();
}
?>
---------- END login.php
---------- frame.php
<?php
session_start();
//echo $susuario;exit();
if (!isset($susuario)) { // <---- HERE the problem!!! susuario is unset???????
header("Location: http://pathto/index.html");
exit();
}
?>
<frameset cols="15%,*">
<frame name="izquierda" src="izquierda.php" marginwidth="10" marginheight="10" scrolling="auto" frameborder="0">
<frame name="derecha" src="derecha.php" marginwidth="10" marginheight="10" scrolling="auto" frameborder="0">
</frameset>
---------- END frame.php
How is posible???
But the most curious thing is that when I "execute" the index.html for the first time frame.php send me to
index.html because $susuario is not set, but if try it again the frame.php execute the frame code perfectly.
I am very confused, any suggestion or comment will be very appreciable.
Thank you for read this,
David.