I am trying to authenticate to my site.  I have had no
success.  All I get is the pop-up window reutrning
over and over again.  Like it is not even looking at
the code. Please help.  This seems like standard stuff
floating around various php sits so why it doesn't
work is a mystery.

Here is my code.

<?

if (!isset($PHP_AUTH_USER)) {
                
        header('WWW-Authenticate: Basic realm="My Private
Stuff"');
        header('HTTP/1.0 401 Unauthorized');
        echo 'Authorization Required.';
        exit;

} else {

        $connection = mysql_connect("localhost", "dude",
"pass")
                or die ("Couldn't connect to server.");
                
        $db = mysql_select_db("scis", $connection)
                or die ("Couldn't select database.");

        $sql = "SELECT userid 
                FROM regiuser
                WHERE userid='$PHP_AUTH_USER' and
password='$PHP_AUTH_PW'";

        $result = mysql_query($sql)
                or die("Couldn't execute query.");

        $num = mysql_numrows($result);

        if ($num == 1) {

                echo "<P>You are valid!<br>";
                echo "Your userid is $PHP_AUTH_USER<br>";
                echo "Your password is $PHP_AUTH_PW</p>";

        } else if ($num == 0)  {

                echo "You are not authorized!";

        }

}

?>

__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to