I made code that allows you to login. Whenever you login, I have it set a session variable, named $_SESSION['username'], equal to the username that has been logged in. However, when I progress my way to the next page, the same variable which I have declared earlier is no longer available. Yes, I have started the session in each page. Here is the code from the login pages:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
session_start();
require("connect.php");
mysql_select_db("userdatabase") or die(mysql_error());
$username = $_POST["username"];
$password = $_POST['password'];
$check_attributes_ = mysql_query("SELECT * FROM users WHERE username='$username'");
$check_attributes = mysql_fetch_array($check_attributes_);
echo $check_attributes['username'] . " == " . $username;
if ($check_attributes['username'] == $username) {
if ($check_attributes['password'] == $password) {
$_SESSION['username'] = $check_attributes['username'];
$_SESSION['admin'] = $check_attributes['admin'];
$_SESSION['mod'] = $check_attributes['mod'];
?>
<html>
<head>
<title>
unline site
</title>
<link rel="stylesheet" type="text/css" href="my_style_sheet.css" />
</head>
<body>
<center>
<table class="header">
<tr>
<td>
<a href = "index.php"> Home </a>
</td>
<td>
<a href = "blog.php"> Blog </a>
</td>
<td>
<a href = "contactinfo.php"> Contact info </a>
</td>
<td>
<a href = "forum.php"> Forum </a>
</td>
</tr>
</table>
<a class="small_stuff" href="cpanel.php">
Administrator cpanel
</a>
</center>
<p class="normal">Successfully Logged in</p>
<form action="profile.php" method="post">
<input type="submit" name="submit" value="Continue">
</form>
<?php
}
else {
?>
<p class="normal">Incorrect password.</p>
<?php
}
}
else {
?>
<p class="normal">Incorrect username.</p>
<?php
}
?>
</body>
</html>

Then it gets to this page where it displays "!You must be logged in to view this page!"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
session_start();

echo $_SESSION['username'] . "!";

if ($_SESSION['username']) {
echo "Welcome " . $_SESSION['username'] . "!";
echo "<br /><a href='logout.php'>Logout</a>";
}
else {
echo "You must be logged in to view this page!";
}
?>
<html>
<head>
<title>
unline site
</title>
<link rel="stylesheet" type="text/css" href="my_style_sheet.css" />
</head>
<body>
<center>
<table class="header">
<tr>
<td>
<a href = "index.php"> Home </a>
</td>
<td>
<a href = "blog.php"> Blog </a>
</td>
<td>
<a href = "contactinfo.php"> Contact info </a>
</td>
<td>
<a href = "forum.php"> Forum </a>
</td>
</tr>
</table>
</center>
<center>
<a class="small_stuff" href="cpanel.php" target="_blank">
Administrator cpanel
</a>
</center>
</body>
</html>


Please help me figure this out.