RE: [phplib] Loginform on every page From: Matt Williams (matt <email protected>)
Date: 04/06/01

Here's a bit of code that someone sent me. Works for me.

Add this to your auth class in local.inc
---------------------------------------------
function login_if($attempt) {
      global $sess, $username, $password;

      $challenge = md5(uniqid($this->magic));
      $sess->register("challenge");

    if ($attempt && ( "nobody" == $this->auth["uid"])) {
      $uid = false;
      $uid = $this->auth_validatelogin();
    }

    if($uid) {
      $this->auth["uid"] = $uid;
      $this->auth["uname"] = $username;
    }
    return $challenge;
}
-----------------------------------------------

The put this after page open
-----------------------------------------------
$challenge = $auth->login_if($username);
-----------------------------------------------

If the username/password is wrong check if username is set to print the
error.
ie.
if(isset($username))
{
  // wrong username/password message
}

HTH

M@

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>