Having to hit the site login button twice after first turning on computer
- by John
Hello,
The code below is for a login that I'm using.  It works fine, but when I first try logging in after turning on my computer, it only works the second time that I hit the "Login" button.  Any idea how I can make it not require hitting the "Login" button twice in this situation?
Thanks in advance,
John
function isLoggedIn() { 
  if (session_is_registered('loginid') && session_is_registered('username')) { 
    return true; // the user is loged in 
  } else { 
    return false; // not logged in 
  } 
  return false; 
}
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();
}
function show_loginform($disabled = false)
{
    echo '<form name="login-form" id="login-form" method="post" action="./index.php"> 
    <div class="usernameformtext"><label title="Username">Username: </label></div> 
    <div class="usernameformfield"><input tabindex="1" accesskey="u" name="username" type="text" maxlength="30" id="username" /></div> 
    <div class="passwordformtext"><label title="Password">Password: </label></div> 
    <div class="passwordformfield"><input tabindex="2" accesskey="p" name="password" type="password" maxlength="15" id="password" /></div> 
    <div class="registertext"><a href="http://www...com/sandbox/register.php" title="Register">Register</a></div> 
    <div class="lostpasswordtext"><a href="http://www...com/sandbox/lostpassword.php" title="Lost Password">Lost password?</a></div> 
  <p class="loginbutton"><input tabindex="3" accesskey="l" type="submit" name="cmdlogin" value="Login" ';
    if ($disabled == true)
    {
        echo 'disabled="disabled"';
    }
    echo ' /></p></form>';
}
EDIT:  Here is another function that is used.
function isLoggedIn()
{
    if (session_is_registered('loginid') && session_is_registered('username'))
    {
        return true; // the user is loged in
    } else
    {
        return false; // not logged in
    }
    return false;
}