The connection with the database is working properly.
I'm working on a Linux Server, and as fas as I can tell, sessions are enabled . The sessions are configured to go into the /tmp folder.
The connection with the database is working properly.
I'm working on a Linux Server, and as fas as I can tell, sessions are enabled . The sessions are configured to go into the /tmp folder.
Hi,
This is a guess, but I think I've seen it before ... try putting exit(); just after all calls to header() ...
<?php
if (mysql_num_rows($result)!=0){
// como el usuario fue reconocido, se activa una sesion y se guarda el permiso
session_start();
session_register("autentificado");
$autentificado="si";
header("Location:visualizacion.php");
exit();
}
else{
//aqui es donde se redirecciona al tipo de regreso
header("Location:acceso.php?fallo=si");
exit();
}
?>
Pau;
Done. It keeps showing the same error.
Grrr, I thought that might be it!!
OK, can you try this ...
<?php
if (mysql_num_rows($result)!=0){
// como el usuario fue reconocido, se activa una sesion y se guarda el permiso
session_start();
session_register("autentificado");
$autentificado="si";
echo 'visualizacion';
//header("Location:visualizacion.php");
}
else{
//aqui es donde se redirecciona al tipo de regreso
echo 'fallo';
//header("Location:acceso.php?fallo=si");
}
?>
... to see what happens.
Paul
Tried, too. When I write a wrong password, it displays "fallo" but when I write the correct one, appears the error again. This appears:
Warning: session_start(): open(/tmp/phpsess/sess_bb34528e6effaac0042c0ce370a9a603, O_RDWR) failed: No such file or directory (2) in /var/www/html/etec/egresados/comprobacion.php on line 20
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/html/etec/egresados/comprobacion.php:20) in /var/www/html/etec/egresados/comprobacion.php on line 20
visualizacion
Warning: Unknown(): open(/tmp/phpsess/sess_bb34528e6effaac0042c0ce370a9a603, O_RDWR) failed: No such file or directory (2) in Unknown on line 0Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp/phpsess) in Unknown on line 0
"Visualizacion" is there, among the error lines
Check to see if your session.save_path has been set in the php.ini file.
P.
It is set like this:
session.save_path = /tmp/phpsess
Hmmm, running out of ideas.
Try ...
<?php
if (mysql_num_rows($result)!=0){
// como el usuario fue reconocido, se activa una sesion y se guarda el permiso
session_start();
$_SESSION['autentificado']="si";
//header("Location:visualizacion.php");
}
else{
//aqui es donde se redirecciona al tipo de regreso
echo 'fallo';
//header("Location:acceso.php?fallo=si");
}
?>
err, sometimes it's the simplest things that cause the problems....
Did you read and take note of the error?
It relates to Line 20 of the script....
Your line 20 is:
session_register("autentificado");
$autentificado="si";
You are trying to register an empty session variable.
Try declaring $autentificado="si"; BEFORE session_register("autentificado");
I would also consider looking at your if statement relating to the number of returned rows. Surely any result except exactly ONE row should result in fail. Yours just states that it will fail only if the number of returned rows is 0.
and can you check that the path
/tmp/phpsess/
exists and is writeable by the web server, as I don't think that php will create the path, and if it cannot write into the directory then it cannot store the session information.
Does PHP have rights to write to the directory which you store sessions in?
Guys, you're awesome. It's working now!
The code ended like this:
<?php
// conexion con la base de datos donde se encuentra la lista de usuarios
$conn = mysql_connect("localhost","root","proyecto")or die("No se puede establecer conexion");
// selecciono la base de datos que voy a usar, que es la de los egresados
mysql_select_db("ITCHII_EGR",$conn);
// saco los valores enviados del arreglo POST
$ncontrol = $_POST[nc];
$contrasena = $_POST[cont];
// se establece la instruccion de MySQL con los datos obtenidos de la pagina anterior
$ssql = "select * from t_entrada where nc='$ncontrol' and contrasena='$contrasena'";
// se busca el registro con los datos obtenidos de la pagina anterior, en la tabla que tiene los usuarios
// con acceso permitido
$result = mysql_query($ssql,$conn);
// aqui se revisa si hay algun resultado. Si existe, entonces esta autorizado, pero si no encontro
// nada, es que la contraseΓ±a fallo o tal ves el numero de control. De cualquier forma, se le
// regresa a la pagina de acceso
if (mysql_num_rows($result)==1){
// como el usuario fue reconocido, se activa una sesion y se guarda el permiso, ademas de enviar el
// nc del usuario a la siguiente pagina.
Session_start();
$autentificado='si';
$session_register['autentificado'];
// echo "visualizacion";
header("Location:visualizacion.php?nc=$_POST[nc]");
exit();
}
else{
//aqui es donde se redirecciona al tipo de regreso
// echo "fallo";
header("Location:acceso.php?fallo=si");
exit();
}
// aqui libera el espacio de memoria ocupado por la busqueda de sql
mysql_free_result($result);
// cierra la conexion con la base de datos
mysql_close($conn);
?>
The variable "autentificado" do needed to have a value to be registered
Apache couldn't save on "phpsess" folder. I had to get the manager of the server to change that
The "exit()" expression worked, too
Now I can read "$autentificado" in the others .php files
Thanks again everyone!!
Note: SIWIS, the IF statement was meant only to fail if there was no one with that nc in the table, but since it is the ID, that there are more than one is a error too. I changed it, thanks.