Before a session will register (or be resumed on a new page), you have to start the session engine with session_start(). Also, this must be called prior to any other output since it involves headers, so place it at the top of your script.
Hope that helps.
*Edit: something like this:
Code:
<?php session_start(); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head><title>Assignment Administration</title></head>
<body>
<?php
require_once("http://www.tipsymich.tvu.farstate.net/assignment/includes/includeFiles.inc");
?>
<?php
if (isset($_POST['login']))
{
$username = ($_POST['username']);
$password = ($_POST['password']);
$Query = @mysql_query("SELECT username, password, usertype FROM login WHERE username = '$username' AND password = '$password'");
$row = mysql_fetch_array($Query);
$usertype = $row ['usertype'];
$num_rows = mysql_num_rows($Query);
if($num_rows < 1){
print("Sorry, you're login details were not recognised, Please use the back button on you're browser to try again.");
}
if ($Query)
{
$_SESSION['authorised'] = TRUE;
}
}
if (isset($_REQUEST['logout']))
{
unset($_SESSION['authorised']);
}
if (isset($_SESSION['authorised']))
{
if ($usertype == 'Staff')
{
?>
<h1>Staff Administration</h1>
<p><a href="postass.php">Post an assignment</a></p>
<p><a href="stuass.php">View Student's Assignments</a></p>
<p><a href="<?php echo $_SERVER['PHP_SELF']; ?>?
logout=1">Logout</a></p>
<?php
} else if ($usertype == 'Student') {
?>
<h1>Student Administration</h1>
<p><a href="submitass.php">Submit an Assignment</a></p>
<p><a href="postass/">View Posted assignments</a></p>
<p><a href="viewfedbak.php">View feedback</a></p>
<p><a href="viewgrade.php">View Grade</a></p>
<p><a href="<?php echo $_SERVER['PHP_SELF']; ?>?logout=1">Logout</a></p>
<?php
}
} else echo'<h1> You are not authorised to view this site!</h1>'
?>
</body>
</html>
Bookmarks