Include in your headers:
PHP Code:
include('authenticate.php');
File authenticate.php:
PHP Code:
<?php
function authenticate() {
header('WWW-Authenticate: Basic realm="Admin"');
header('HTTP/1.0 401 Unauthorized');
print "NOT AUTHORIZED";
exit;
}
if (!isset($_SERVER['PHP_AUTH_USER'])) { authenticate(); } else {
$result = mysql_query("SELECT * FROM user_table WHERE username='$_SERVER[PHP_AUTH_USER]' and password='$_SERVER[PHP_AUTH_PW]' LIMIT 1");
if (mysql_num_rows($result)) {
$user = mysql_fetch_array($result, MYSQL_ASSOC);
} else {
authenticate();
}}
?>
Best Regards,
Adult SEO