Probaj ovo
Code:
<?PHP
// include this file where you want to limit access.
$username = "test";
$password = "123";
function authenticate() {
Header( "WWW-authenticate: basic realm=\"Protected\"");
Header( "HTTP/1.0 401 Unauthorized");
echo "You must enter a valid login ID and password!\n";
exit;
}
function CheckPwd($user,$pass) {
global $username,$password;
return ($user != $username || $pass != $password) ? false : true;
}
if(!isset($PHP_AUTH_USER)) {
authenticate();
}
elseif(!CheckPwd($PHP_AUTH_USER,$PHP_AUTH_PW)) {
authenticate();
}
?>
<html>
<head>
<title>Authentication System</title>
</head>
<body bgcolor="#FFFFFF">
<font face="Verdana, Arial" size="2"><b>Welcome,</b></font>
<hr size="1" width="300" align="left">
<font face="Verdana, Arial" size="2">You have
authenticated successfully!</font>
</body>
</html>