The page after I login displays Logged in as: username
Any page after that does. Does anyone know why it doesn't do it on the other pages?
<?
// include function files for this application
session_start();
require_once("include_fns.php");
$username = $_POST['username'];
$passwd = $_POST['passwd'];
if ($username && $passwd)
// they have just tried logging in
{
if (login($username, $passwd))
{
// if they are in the database register the user id
$valid_user = $username;
session_register("valid_user");
}
else
{
// unsuccessful login
do_html_header("Problem:");
echo "You could not be logged in.
You must be logged in to view this page.";
do_html_url("login.php", "Login");
do_html_footer();
exit;
}
}
do_html_header("Home");
check_valid_user();
// give menu of options
display_user_menu();
do_html_footer();
?>
check_vaild_user on another pages displays who is logged in...Here is the code
function check_valid_user()
// see if somebody is logged in and notify them if not
{
global $valid_user;
if (session_is_registered("valid_user"))
{
echo "Logged in as: $valid_user";
echo "<br>";
}
else
{
// they are not logged in
do_html_heading("Problem:");
echo "You are not logged in.<br>";
do_html_url("login.php", "Login");
do_html_footer();
exit;
}
}