401 Authorization Required"; echo "This server could not verify that you are authorized to access the document requested. "; echo "Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't "; echo "understand how to supply the credentials required. "; //echo ""; //echo "click here to try again."; } function authenticate() { Header("WWW-Authenticate: Basic realm=\"Real User\", stale=FALSE"); Header("HTTP/1.0 401 Unauthorized"); no_auth_msg(); exit; } // ///// authenticate /////// // $host="hamlog.db.7270617.hostedresource.com"; // $host="p3nlhdb5020-11.shr.prod.phx3.secureserver.net"; $name="hamlog"; $pass="gd_user_SQL_44"; $dbname="hamlog"; mysql_connect($host,$name,$pass) or die("Unable to connect to database"); mysql_select_db($dbname) or die("Unable to select database"); if (isset($_SERVER['PHP_AUTH_USER'])) { $PHP_AUTH_USER = $_SERVER['PHP_AUTH_USER']; $PHP_AUTH_PW = $_SERVER['PHP_AUTH_PW']; // Verify username and pw $sql = "SELECT * FROM users WHERE username=\"$PHP_AUTH_USER\" AND password=\"$PHP_AUTH_PW\""; if (!($result = mysql_db_query("hamlog", $sql))) { die("Unable to access database. Please try again later."); } if (mysql_num_rows($result) > 0) { // do nothing // User is valid move along } else { // User is not valid authenticate(); } } else { // username is not yet set // Show authentication dialogue authenticate(); } ?>