if (!isset($_SERVER['PHP_AUTH_USER'])) { header("HTTP/1.0 401 Unauthorized"); header("WWW-Authenticate: Basic realm=Webstats"); die; } else { $dblink = mysql_connect ("", "webstats", "w5Y1v1o2"); if (!$dblink) { echo "Database is down - couldn't login."; } mysql_select_db ("webstats"); $dbres = mysql_query ("select username, stats from user where username='".$_SERVER['PHP_AUTH_USER']."' and password=OLD_PASSWORD('".$_SERVER['PHP_AUTH_PW']."')", $dblink); if (mysql_affected_rows ($dblink) == 1) { list ($user, $stats) = mysql_fetch_row ($dbres); mysql_close ($dblink); } else { mysql_close ($dblink); header("HTTP/1.0 401 Unauthorized"); header("WWW-Authenticate: Basic realm=Webstats"); echo "problem!"; die(); } } ?>