<?php
$validlogin=false;
$thepass=array('pass1', 'pass2', 'pass3');
//=====================================================================
//=====================================================================
if(isset($_COOKIE['validlogin']) && $_COOKIE['validlogin']=='userOK'){
$validlogin=true;
}
else if(isset($_POST['userpass']) && $_POST['userpass']!=''){
foreach($thepass as $key=>$value){
if(trim($_POST['userpass'])==$value){
$validlogin=true;
break;
}
}
}
//=====================================================================
//=====================================================================
if($validlogin){
setcookie('validlogin', 'userOK', time()+3600);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Your web page Title</title>
</head>
<body>
<?php if($validlogin){ ?>
Put web page information here. This will not be visible unless the user is already logged in.<br />
.....................................<br />
.....................................<br />
.....................................<br />
<?php } else { ?>
<form action="" method="post" name="loginform">
<label>Your Password</label>
<input type="password" name="userpass" value="" />
<input name="btnsubmit" type="submit" value="Login" />
</form>
<?php } ?>
</body>
</html>