Thx, now i think that i understand the use of $_SESSION, now this is my problem....
I am using a file to do an authentication using $_SESSION and mysql, but when i write the login and password, the script do nothing and stay without print if the data is correct or not.
What is wrong in my code ??
<?php
session_start();
if(!session_is_registered('auth'))
{
$passwd = md5($POST['frm_passwd']);
if(check_for_rows("SELECT user_name,password FROM usr WHERE user_name='$POST[frm_user]' AND password='$passwd'"))
{
$auth = True;
session_start();
session_register('auth');
$query = "SELECT * FROM usr WHERE user_name='$POST[frm_user]'";
$result = mysql_query($query) or die ("Usuario o clave incorrecta");
$row = mysql_fetch_array($result);
$SESSION['user_name'] = $POST['frm_user'];
$SESSION['user_id'] = $row[user_id];
$SESSION['real_name'] = $row[real_name];
$SESSION['password'] = $row[password];
$SESSION['confirm_hash'] = $row[confirm_hash];
$SESSION['is_confirmed'] = $row[is_confirmed];
echo "El usuario ha sido ingresado";
} else {
echo "<HTML>
<HEAD>
<LINK REL=StyleSheet HREF='incident.css' TYPE='text/css'>
</HEAD>
<CENTER><BR>
<FORM METHOD='post' ACTION='main.php'>
<TABLE BORDER='0'>
<TR><TD CLASS='td_label'>User:</TD><TD><INPUT TYPE='text' NAME='frm_user' MAXLENGTH='255' SIZE='30'></TD></TR>
<TR><TD CLASS='td_label'>Password: </TD><TD><INPUT TYPE='password' NAME='frm_passwd' MAXLENGTH='255' SIZE='30'></TD></TR>
<TR><TD></TD><TD><INPUT TYPE='submit' VALUE='Log In'></TD></TR>
</FORM></CENTER>
</HTML>";
exit();
}
}
function check_for_rows($query)
{
if($sql = mysql_query($query))
{
if(mysql_num_rows($sql) !== 0){
return mysql_num_rows($sql);
} else {
return false;
}
} else {
return false;
}
}
?>