A simple method:
PHP Code:
/* get user auth information into an array ie $userpass['username'] = pass */
if($userpass[$PHP_AUTH_USER] == $PHP_AUTH_PW)
{
continue;
}
else
{
//send headers to cause browser to request user and pass from user
header("WWW-authenticate: Basic realm=\"realm name\"");
header("HTTP/1.0 401 Unauthorized");
print("notice that the user isnt authorised");
}