Use the session.
First put the following at the top of all your pages (it has to go before any output):
session_start();
On your login form (after you have verified the user), add the following:
if ($validuser) {
$SESSION["user"] = $username;
$SESSION["password"] = $password;
header("Location: mainpage.php");
exit();
}
else {
//Show login form.
}
This stores the user details and redirects to the start page.
I would put at the top of each page something like this (after the above mentioned session_start):
$username = $SESSION["user"];
$password = $SESSION["password"];
//code to validate user.
if (!$validuser) {
header("Location: login.php");
exit();
}
This means that someone can't jump straight to a page inside your site without logging in.
Hope this is helpful.
James