posir 发表于 2017-3-4 07:24:11

PHP HTTP Authentication

  


<?php
$config['admin_username'] = "demo";
$config['admin_password'] = "demo";
if (!($_SERVER['PHP_AUTH_USER'] == $config['admin_username'] && $_SERVER['PHP_AUTH_PW'] == $config['admin_password'])) {
header("WWW-Authenticate: Basic realm=\"Papermashup.com Demo Admin\"");
header("HTTP/1.0 401 Unauthorized");
echo 'This is what happens if you press cancel';
?>
<?php
exit;
}
// if the username and password match show the rest of the content
?>
 
页: [1]
查看完整版本: PHP HTTP Authentication