Frank

I'll guess you are using v4.2.x of PHP - well the $PHP_AUTH_USER probably
won't be set as now the default installation has the register_globals
directive set to off rather than on... this has broken lots of existing
code...

You have 2 options...

1) Switch back on register_globals in php.ini (NB there are security
implications in doing that btw)
2) Use the new super globals - these are arrays that are always defined in
the global scope ... so in this case use $_SERVER['PHP_AUTH_USER']

HTH
Rich


-----Original Message-----
From: Frank Tudor [mailto:[EMAIL PROTECTED]]
Sent: 24 July 2002 14:18
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] PHP WIN2K MYSQL Authentication


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


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

Reply via email to