<?php
$auth=0;
if(isset($_SERVER[‘PHP_AUTH_USER’]))
{
$uname= $_SERVER[‘PHP_AUTH_USER’];
$pwd= $_SERVER[‘PHP_AUTH_PW’];
$fp= fopen(“users.txt”, “r”);
while($line= fgets($fp))
{
$arr= Explode(“:” $line);
if($uname= $arr[0] and $pwd= trim($arr[1]))
{
$auth=1;
break;
}
}
}
if($auth==0)
header(“www_Authenticate: Basic Realm= mysite”);
else
header(“location: welcome.php”);
?>
welcome.php
<?php
echo “Welcome to”.$_SERVER[‘PHP_AUTH_USER’];
?>