Hi. my check_valid_user function is not working properly here. My login form brings me to member.php which contains the following:
<?php
session_start ();
require_once ('all_functions.php');
$username = $HTTP_POST_VARS ['username'];
$passwd = $HTTP_POST_VARS ['user_password'];
//$date = $HTTP_POST_VARS [date("l dS of F Y h:i:s A")];
display_header ();
display_logout ();
?>
</table>
</center>
<?php
if ($username && $passwd)
{
if (login ($username, $passwd))
{
// if they are in the database, register the ID.
$HTTP_SESSION_VARS ['valid_user'] = $username ;
}
else
{
//unsuccessful login
echo '<p align="center"> <b>You could not be logged in. You must be logged in to view this page.</b></p>';
display_login_form ();
exit ();
}
}
check_valid_user ();
?>
The problem is when I exclude check_valid_user () on member.php , my login is successfull but when I include it, it shows the message:
'Warning! You are not logged in. Please log in here.'
This is the error message inside my check_valid_user function.
Here is my complete check_valid_user function:
function check_valid_user ()
//see if somebody is logged in and notify them if they are not
{
global $HTTP_SESSION_VARS;
if (isset ($HTTP_SESSION_VARS ['valid_user']))
{
echo ' You are logged in as:<b><font color="#0000FF"> '. $HTTP_SESSION_VARS ['valid_user'].'</font> </b>.';
echo '<br />';
echo 'Today is: '. date("l dS of F Y "). '<br/>';
}
else
{
echo '<b><font color="#FF0000"> <p align="center">Warning!</font> You are not logged in. Please log in here.</b></p>';
display_login_form ();
exit;
}
}
If someone had the same problems before, I apologize. You can refer me to other threads. Thanks 🙂