Forum Moderators: coopster

Message Too Old, No Replies

sessions and globals off-on

         

helenp

12:34 am on Nov 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi I just done my first sessions....after many hours,
the codes works perfect on my server that has globals set OFF but donīt work on my PC wich is globals ON.

I always make the scripts work on both, that way I wonīt have any troubble if my host upgrades and switch the globals.

This is the code and I cant figure out why it donīt work on my pc, well the redirection works but canīt find the variable in the select:

First loginpage:
<form action="control.php" method="POST">
<td><input type="Text" name="usuario"td>
<td><input type="password" name="pass""></td>

code in control.php:
$usuario = $_POST['usuario'];
$pass = $_REQUEST['pass'];
mysql_select_db ("reservas", $dbh);
$ssql = "SELECT * FROM usuarios WHERE usuario='$usuario' and pass='$pass'";
$rs = mysql_query($ssql);
if (mysql_num_rows($rs)!=0){
//usuario y contraseņa válidos
//defino una sesion y guardo datos
session_start();
$usuario = $_POST['usuario'];
$pass = $_REQUEST['pass'];
$_SESSION['usuario'] = $usuario;
session_register("autentificado");
$autentificado = "SI";
header ("Location: url.php");
}else {
//si no existe le mando otra vez a la portada
header("Location: index.php?errorusuario=si");
}
mysql_free_result($rs);
mysql_close($conn);

Code in url.php
starts with:
session_start();
$usuario = $_REQUEST['usuario'];
$pass = $_REQUEST['pass'];
header("Cache-control: private"); //IE 6 Fix

then the select:
$result = mysql_query("SELECT propiedades.id, from propiedades, usuarios LEFT JOIN bookings ON propiedades.id_reservas = bookings.id WHERE propiedades.id_propiedad = usuarios.id_propiedad AND usuarios.usuario = '$usuario'", $dbh);

helenp

11:49 am on Nov 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Finally I fixed it
adding $usuario =$_SESSION['usuario'];

coopster

2:22 pm on Nov 22, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Glad you got it sorted.

I code for register_globals OFF, period. If the host won't allow a change or override to that configuration directive, I recommend a change in hosting providers ;)