I'm new to PHP and web programming in general - so this may seem like a stupid question but here it is anyway:

I'm trying to password protect an area of a site. The only page that needs to be protected though, is the main index page for the area (theoretically someone could get into the other pages behind it if they knew the URL, but i'm not worried about that because of the obscure names of the pages)

I can get a password from the user, pass it to the index page, and it works great, however, when you browse passed the index page, and then click a link for 'back to index' it takes you to the login page again. Here is the code i'm using in the index page:

<?
session_start();
$pagepwd = "julie0407";
if(is_null($password)){
$password = $_POST['password'];

import_request_variables("p", "var");
}
if($password != $pagepwd)
{
header('Location: test1.php');
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>


<a href="test3.php">Click for page 3</a><br>
the password is <?= $password ?>


</body>
</html>


and here is the code in the logon page:

<?php
session_start();
session_register('password');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>form test 1</title>
</head>

<body>
<form action="test2.php" method="post">
Password: <input type="password" name="password" /><br /><br />
<input type="submit" name="login" />

</form>
</body>
</html>

for testing purposes, there's a third document:

<? session_start() ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<p><a href="test2.php">Click for page 2</a><br>
the password is <?= $password ?>
</p>
</body>
</html>