tags:

views:

18

answers:

2

Hello,

The code below is part of a PHP / MySQL login system that I am using. It determines whether or not the login fields are displayed, and it is supposed to only display them when the user is not logged in. Sometimes it displays them when is user is logged in, logging the user out.

Any ideas on what I should look for to trouble shoot this?

Thanks in advance,

John

<?php
if (!isLoggedIn())
{

    if (isset($_POST['cmdlogin']))
    {

        if (checkLogin($_POST['username'], $_POST['password']))
        {
            show_userbox();

        } else
        {
            echo "Incorrect Login information !";
            show_loginform();
        }
    } else
    {

        show_loginform();
    }

} else
{

    show_userbox();

}

?>
A: 

You might try :

<?php
if (!isLoggedIn())
{

    if (isset($_POST['cmdlogin']))
    {

        if (checkLogin($_POST['username'], $_POST['password']))
        {
            show_userbox();

        } else
        {
            echo "Incorrect Login information !";
            show_loginform();
        }
    } else
    {

        show_loginform();
    }
    exit();

} else
{

    show_userbox();

}

?>
Kaaviar
A: 

What you want to do is reevaluate the return values of the functions. Make sure they always return a boolean.

I can't see the source of the other functions, so perhaps it's a good idea to take a look at the code from isLoggedIn() and CheckLogin ;)

Greetings, Stephen

Stephen