ITeye博客

PHP HTTP Authentication

keshion · 2012-11-22 17:39 · PHP · 编程语言 · Markdown

<?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
 
?>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。