ok heres the situation now. I made it where it emptys the $Post data after its done useing it. if the users info is valid it shows them their content and delets the $POST vars. when I click the back button on any page. it NO LONGER puts the ERROR up. 😃 but now when I press the forward button the error pops up. but I only get the error when I log in and then immediately press the back button and then try to press the forward button. If I log in and click on a link then press the back button and followed by the forward, I get no error.
Im a little confused cause the syntax that submits the form doesnt execute if the $_POST isnt filled ,in which it isnt. so now whats the problem. Since all my syntax is on one document, i will show you guys it and you guys give your oppinion
<?php session_start(); ?>
<?php if ($_SESSION['user']==""){ $userStatus = "Not logged In! ";}?>
<?php if ($_POST['loginName'] != "" && $_POST['password'] !=""){?>
<?php require_once('Connections/ok.php');?>
<?php
mysql_select_db($database_ok,$ok);
$query = sprintf("SELECT firstName, loginName, passWord, USERID
FROM users
WHERE loginName = '%s'",mysql_real_escape_string($_POST['loginName']));
$results = mysql_query($query) or die("Query failed ($query): " . mysql_error());
$check = mysql_fetch_assoc($results);
if (strcasecmp($check['loginName'],$_POST['loginName']) == 0
&& strcmp($check['passWord'],$_POST['password']) == 0
&& !$check['passWord']== "" && !$check['loginName'] == "") {
$_SESSION['user'] = array('firstname'=>$check['firstName'],'userID'=>$check['USERID'],'loginName'=>$check['loginName']); empty($_POST['loginName']); empty($_POST['passWord']);} else { $status = "failed"; }?>
<?php }?>
<!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"><!-- InstanceBegin template="/Templates/insert.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<link href="style.css" rel="stylesheet" type="text/css" />
<!-- InstanceBeginEditable name="head" -->
<link href="admin.css" rel="stylesheet" type="text/css" />
<!-- InstanceEndEditable -->
<link href="admin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<div id="top">
<div id="title">Title</div><div id="UserStatus"><?php if(!$_SESSION['user']==""){
echo "Welcome ". $_SESSION['user']['firstname'];}else{echo "Not logged In";} ?></div>
</div>
<div id="menu"><ul><li>menu</li></ul></div>
<div id="content">
<!-- InstanceBeginEditable name="EditContent" -->
<?php if ($_SESSION['user'] == ""){ ?>
<?PHP
//below is just the login Page. If the session above is notdefined
//which indicates that the user is not logged in, then the login page
//is displayed ?>
<table border="0" cellspacing="0" cellpadding="0">
<form action="admin.php" method="post">
<tr>
<td width="82">Login:</td>
<td width="144"><input type="text" name="loginName" /></td>
</tr>
<tr>
<td>Password: </td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="login" /></td>
</tr>
</form>
</table>
<?php }?>
<?php if (!$_SESSION['user'] ==""){ $status = "Login success";?>
<div id="admin">
<?PHP
// if var session user is defined then a menu pops up that allows the
//user to click on links ?>
<div id="adminMenu"><ul><li>New Product</li><li><a href="admin.php?admin=2">New Category</a></li><li></li></ul></div>
<?php echo $status ?>
</div>
<?php }?>
<?PHP
//if the user clicks on the link then the content below is displayed ?>
<?php if ($_GET['admin'] == 2){?>
<div id="newCat">
<table width="288" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="138">Category Name: </td>
<td width="150"><input type="text" name="textfield" /></td>
</tr>
<tr>
<td height="55">Category Description </td>
<td><textarea name="textarea" rows="5" cols="50"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit2" value="Submit" /></td>
</tr>
</table>
</div>
<?php }?>
<!-- InstanceEndEditable -->
</div>
</div>
<div id="bottom">
</div>
</body>
<!-- InstanceEnd --></html>
I guess what I solved so far isnt too bad. cause I only get the error if log in and click back and then click forward. I dont get the error if i log in and click on a link or something then click back and then decide to click forward again. I guess I can probably live with that. But if anybody can still find out why i get the error when I log in and click the back button and then click the forward button. that would be great.
So i guess when all said and done. another better way is to empty your $POST varibles. and wrap your inserts and queries with controls to check if your forms are filled, if so, then carry out actions and empty $POST afterwards. and make sessions to tell the server that the user already signed in and doesnt need to do it again.