I have this code on the page: <?php /*This just checks to ensure they filled in username and password.*/ if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'Text to send if user hits Cancel button'; exit; } else { echo "Hello ".$_SERVER["PHP_AUTH_USER"].".<P>"; echo "You entered ".$_SERVER["PHP_AUTH_PW"]." as your password.<P>"; } ?> Code (markup): Everytime I run the page, it keeps popping up with the user name/password prompt, even when I enter both a user and password. It eventually just fails...as far as I know this should be working fine, and I don't know how to resolve it.
That code sample works fine for me. AFAIK you need PHP to be installed as module for it to work. If your PHP is installed in CGI mode, then the example above won't work, because $_SERVER['PHP_AUTH_USER'] variable is not being set.