// userauth.php code starts below $realm = "Directory Name"; $username = "username"; $passwd = "password"; $PHP_AUTH_USER = $_SERVER['PHP_AUTH_USER']; $PHP_AUTH_PW = $_SERVER['PHP_AUTH_PW']; $err_msg = " Invalid Username/Password Entered

Invalid Username/Password Entered

You must enter your username and password.
If you do not have a valid username and password,
you probably shouldn't be here.

"; function auth_reject() { global $err_msg, $realm; Header("HTTP/1.0 401 Unauthorized"); Header("WWW-Authenticate: Basic realm=\"$realm\""); print "" . $err_msg . ""; exit(); } # check to see if username is set if (!isset($PHP_AUTH_USER)) { auth_reject(); } # check to see if password is set if (!isset($PHP_AUTH_PW)) { auth_reject(); } # check username if ($PHP_AUTH_USER != $username) { auth_reject(); } # check password if ($PHP_AUTH_PW != $passwd) { auth_reject(); } // end userauth code