http://il.php.net/features.http-auth
PHP קוד:
<?php
/*
* qq: 290359552
* return string : "error" or array("user","pass");
*/
function auth()
{
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
return "error";
} else {
return array( $_SERVER['PHP_AUTH_USER'] , $_SERVER['PHP_AUTH_PW'] );
}
}
// test:
$au= auth();
print_r( $au );
?>