<?php
$user = '認證帳號';
$pw = '認證密碼';
$user = '認證帳號';
$pw = '認證密碼';
if(!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_PW']=='') {
Header("WWW-Authenticate: Basic realm=\"login\"");
Header("HTTP/1.0 401 Unauthorized");
die('認證失敗');
} else {
if($_SERVER['PHP_AUTH_USER']!=$user || $_SERVER['PHP_AUTH_PW']!=$pw) {
Header("WWW-Authenticate: Basic realm=\"login\"");
Header("HTTP/1.0 401 Unauthorized");
die('帳號或密碼錯誤');
}
}
Header("WWW-Authenticate: Basic realm=\"login\"");
Header("HTTP/1.0 401 Unauthorized");
die('認證失敗');
} else {
if($_SERVER['PHP_AUTH_USER']!=$user || $_SERVER['PHP_AUTH_PW']!=$pw) {
Header("WWW-Authenticate: Basic realm=\"login\"");
Header("HTTP/1.0 401 Unauthorized");
die('帳號或密碼錯誤');
}
}
echo "認證成功";
沒有留言:
張貼留言