经测试代码如下:
<?PHP /** * HTTP认证 * * @param * @arrange (512.笔记) jb51.cc **/ // input user/pass below $username = "INSERT YOUR DESIRED USERNAME HERE"; $password = "INSERT YOUR DESIRED PASSWORD HERE"; // password protect via http if(!(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) && $_SERVER['PHP_AUTH_USER'] == $username && $_SERVER['PHP_AUTH_PW'] == $password)){ header('WWW-Authenticate: Basic realm="Secured Area"'); header('Status: 401 Unauthorized'); }else{ /*** 来自:编程之家 jb51.cc(jb51.cc) ***/ ?>
@H_502_6@ 经测试代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <Meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Page Name jb51.cc</title> </head> <body> <!-- // html --> </body> </html> <?PHP } ?>
@H_502_6@