I think I did this right... just one problem which isn't really a problem but I'd rather this not happen...
if a user logs in and then follows a link off the page (really just home right now) and then comes back by typing .../admin.php in the adress bar, the session resumes. I don't know if its supposed to do this or its just a bug
if back is pressed after the link then a warning: page has expired message is displayed... thats good...
ideally, I want "No username entered" displayed for typing in admin.php manually... I think what I want is to execute session_unset() whenever I go to any page that isn't admin.php...
admin.php
<?php
session_name('localhost_editor');
session_start();
?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>FRED administration</title>
</head>
<body link="Black" vlink="Black" alink="Black">
<center>
<br />
<br />
<h1>Go <a href="http://localhost/home/">Home</a></h1>
<br />
<br />
<?php
if (isset($_POST['uname'])) $_SESSION['uname'] = $_POST['uname'];
elseif (!isset($_SESSION['uname'])) die("No Username Entered</center></body></html>");
$uname = $_SESSION['uname'];
if (isset($_POST['pword'])) $_SESSION['pword'] = $_POST['pword'];
elseif (!isset($_SESSION['pword'])) die("No Password Entered</center></body></html>");
$pword = $_SESSION['pword'];
$dbconn = mysql_connect();
mysql_select_db('portal');
$sql = "SELECT * FROM users WHERE uname LIKE '$uname' AND pword LIKE '$pword'";
if (mysql_num_rows(mysql_query($sql)))
{
?>
LOGGED IN
<?php
}
else
{
echo "INCORRECT USERNAME/PASSWORD";
session_unset();
}
session_write_close();
?>
</center>
</body>
</html>