I'm using the code below to direct people to the page the need to see. It's code that I was given and works great. I give them a password and, when they type it in, it redirects them to their page. The problem is that I need their page to be protected so that only the person who come from this page, and type in the right password, can access the page. If they try to go to the page directly, without going through this page, they get an error message. Is that possible? If so, what php code would I put at the top of each page. Thanks for your help!
PHP Code:<?php
$sites = array(
'password1' => 'http://www.kgcr.org',
'password2' => 'http://www.colbyberean.com/jobs.php',
'password3' => 'http://www.kgrd.org'
);
$password = isset($_POST['password']) ? trim($_POST['password']) : '';
if($password && isset($sites[$password])) {
header('Location: ' . $sites[$password]);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
body {margin: 0;padding: 0;background:#222 url('splash.gif') no-repeat top left;}
#login {margin: 245px 0 0 245px;}
#login p {margin: 2px 0 0 45px;}
#login input {padding: 5px;color: #666}
#login input:focus {color: #000}
</style>
</head>
<body>
<div id="login">
<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
<input type="password" name="password" size="20" maxlength="100" />
<p><input type="submit" value="Submit" /></p>
</form>
</div>
</body>
</html>



Reply With Quote



Bookmarks