Results 1 to 2 of 2

Thread: Why doesn't this auth stuff work...

  1. #1

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935

    Why doesn't this auth stuff work...

    PHP Code:
    $auth false;
    $authuser $_SERVER['php_auth_user'];
    $authpass $_SERVER['php_auth_pw'];
    if (isset(
    $authuser) && isset($authpass))
    {
        
    $result mysql_query('SELECT name,passhash FROM users WHERE id=1');
        if (!
    $result)
        {
            echo 
    'Failed to determine root user\\'s name.';
            exit;
        }
        else
        {
            $s = mysql_fetch_row($result);
            $name = $s[0];
            $passhash = $s[1];
            if ($authuser == $name && md5($authpass) == $passhash)
            {
                $auth = true;
            }
        }
    }
    if (!$auth)
    {
        header("WWW-Authenticate: Basic realm=\"Garnet Server Login\"");
        header('
    HTTP/1.0 401 Unauthorized');
        echo '
    Login failed.';
        exit;

    I tested the query and it works fine (i.e., returns the name and password hash). But the authentication dialog that pops up never accepts the username and password.

  2. #2

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    Fixed it...changed the case of the array keys for the $_SERVER stuff.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width