i got 2 files, index.php and login.php. on index.php i got
...
if ($SESSION['usuario'] == NULL) {
$SESSION['usuario'] = 'anónimo';
}
...
echo 'Bienvenido <b>' . $_SESSION['usuario'] . '</b></p>';
...
and on login.php:
...
$conexion = mysql_connect('localhost', 'root', 'daniel17071985');
if (!$conexion) {
die('No se pudo establecer una conexion con la base de datos');
}
mysql_select_db('foro');
$query = "SELECT uNombre FROM usuarios WHERE uNombre = '" .
$POST['u_nombre'] . "' AND uPass = '" .
$POST['u_contraseña'] . "'";
$resultado = mysql_query($query);
if (!$resultado) {
die('No se pudo realizar la consulta a la base de datos: ' .
mysql_error());
}
while ($linea = mysql_fetch_array($resultado)) {
$SESSION['usuario'] = $linea['uNombre'];
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Location: [url]http://[/url]' . $SERVER['HTTP_HOST']
. dirname($_SERVER['PHP_SELF'])
. '/index.php');
}
The login script works perfectly fine (finds user ok) and it takes me to index.php. Problem is, on index.php, i get 'Bienvenido anónimo' on the echo, instead of the new name (which happens to be d3k4n :p ) All those other headers appart from location i use to take of the cache on html 1.0 and 1.1. I also tried using if (!isset($_...) and doesn't work either.