...

View Full Version : POSTDATA message on reload.



ScottInTexas
07-30-2007, 07:44 PM
When I click on reload to test some change made to css or the page or whatever, I get a message saying that the page contains POSDATA that if resent will repeat the process such as a purchase or whatever and gives me the option to OK or Cancel. I do have a form on the page, but I am not sending any form data, just reloading. Is there something I have going on that I am not aware of? This is one of the forms. When the user clicks on a menu item the value is inserted into the menu action and the 'HOME' page is recalled checking for the value before sending the header and acting accordingly. But once it gets through the switch statement it's done.



//in the navigation bar
<div id="menuFormDiv" visible="false">
<form action="" id="menuForm" method="post">
<input type="hidden" name="menuaction">
</form>
</div>

//at the top of the home page

$thisPage="Home";
if (isset($_POST['menuaction'])){
switch ($_POST['menuaction']){
case 'Register':
{
require_once "filterClass.php";
//require_once "formFunctions.php";
include("register.php");
$thisPage="Register";
break;
}
default:
$thisPage="Home";
break;
} //end switch
}//end if
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


Is there something I should do to release the post data?

Fumigator
07-30-2007, 09:01 PM
It's that annoying thing browsers do when you reload a page that has POST data in the header. When your menu is clicked, I'm assuming you submit that form which is method="POST" which will pack the form data (your hidden field value) into the header of the http request. Your browser sees this when you reload the page and warns you that it's going to re-send that POST data.

About the only way to avoid this that I know of is to use GET instead of POST, or submit the form to another script and then in that second script call header('location ...') to redirect back to the first page. Of course, if you need to pass data back to the first page from the second page, you'll need to either use a query string or sessions to continue to avoid sending POST data in the header.

StupidRalph
07-31-2007, 12:39 AM
How about using AJAX instead of reloading the page? You can even simplify your work in AJAX by using the AjaxUpdater() which is a part of Prototype (http://www.prototypejs.org), a javascript framework.

ScottInTexas
07-31-2007, 02:42 PM
I don't know a thing about AJAX. And since this is only happening while I reload to test things then I can live with the hassle.

Thanks for you responses.

StupidRalph
07-31-2007, 02:47 PM
Did you even bother to check the link out? Atleast give it a glance, I'm sure you'll be disappointed in yourself for not aspiring to do better. They've written all the code for you to use. Its simple enough for a beginner.

StupidRalph
07-31-2007, 02:51 PM
They have tutorials on the prototypejs.org site BUT if thats not enough try this link at look at the example.

http://www.ajaxtutorial.net/index.php/2006/11/30/simple-ajax-using-prototype-part-2/

firepages
07-31-2007, 04:16 PM
Ajax ???? http headers have been around for a while now ;) see cache-control (http://www.mnot.net/cache_docs/)

ScottInTexas
07-31-2007, 05:32 PM
Thanks firepages. That was just what I needed.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum