Good news - I've got it working. Thanks for your help. I see where I was going wrong.
Bad news - I have only one little niggly problem which may be easily solved.
When you log in, the page doesn't automatically go straight to the intro.php page like it's supposed to. In fact, you have to refresh the page a couple of times before it does this, but after that it works the way it's supposed to.
The pages are found here: http://www.cynicalmatrix.com/webquest/
If you register for an account and try to login in with it, you'll see what I mean. Don't worry. I'll be clearing the database before this goes live. 
Any suggestions as how I could solve this? I really need the page to go straight to intro.php immediately after login. I don't want people to have to refresh the page.
Here's the revised code that I'm using on the page:
PHP Code:
<?php
// Designed and coded by G. Morris 2007
ob_start();
include 'db.inc.php';
//Checks if there is a login cookie
if(isset($_COOKIE['ID_my_site']))
//if there is, it logs you in and directes you to the intro page
{
$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
if ($pass != $info['password'])
{
}
else
{
header("Location: intro.php");
}
}
}
//if the login form is submitted
if (isset($_POST['submit'])) { // if form has been submitted
// makes sure they filled it in
if(!$_POST['username'] | !$_POST['pass']) {
die('<div id=index content align=center><p><img src=images/logo.gif alt=Newcastle College logo width=125 height=69 /></p><p>You did not fill in a required field.</p></div>');
}
// checks it against the database
if (!get_magic_quotes_gpc()) {
$_POST['email'] = addslashes($_POST['email']);
}
$check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error());
//Gives error if user doesn't exist
$check2 = mysql_num_rows($check);
if ($check2 == 0) {
die('<div id=index content align=center><p><img src=images/logo.gif alt=Newcastle College logo width=125 height=69 /></p><p>That user does not exist in our database. <a href=register.php>Click Here to Register</a></p></div>');
}
while($info = mysql_fetch_array( $check ))
{
$_POST['pass'] = stripslashes($_POST['pass']);
$info['password'] = stripslashes($info['password']);
$_POST['pass'] = md5($_POST['pass']);
//gives error if the password is wrong
if ($_POST['pass'] != $info['password']) {
die('<div id=index content align=center><p><img src=images/logo.gif alt=Newcastle College logo width=125 height=69 /></p><p>Incorrect password, please try again.</p></div>');
} else {
// if login is ok then we add a cookie
$_POST['username'] = stripslashes($_POST['username']);
$hour = time() + 3600;
setcookie(ID_my_site, $_POST['username'], $hour);
setcookie(Key_my_site, $_POST['pass'], $hour);
}
}
} else {
// if they are not logged in
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Web Quest :: Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<!-- Page Layout -->
<div id="index content" align="center"><p><img src="images/logo.gif" alt="Newcastle College logo" width="125" height="69" /></p>
<h1>Welcome to the Art & Design Web Quest!</h1>
<p>Make your way around the coloured zones and complete the tasks to gather letters. Crack the code in the Final Zone to enter into our draw prize draw!</p>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<table border="0">
<tr><td colspan=2><h1>Login</h1></td></tr>
<tr><td>Username:</td><td>
<input type="text" name="username" maxlength="40">
</td></tr>
<tr><td>Password:</td><td>
<input type="password" name="pass" maxlength="50">
</td></tr>
<tr><td colspan="2" align="right">
<input type="submit" name="submit" value="Login">
</td></tr>
</table>
</form>
<p>If you have never played before, you need to create a new account in order to save the letters that you have gathered. <a href="register.php">Click here</a> to go to the Register page.</p></div>
<?php
}
?>
</body>
</html>
<?php ob_end_flush(); ?>
Bookmarks