Jump to content

Test POST (clearing the POST cache)


RonInNewYork

Recommended Posts

I'm testing with Chrome. I am writing a directory search program and when I choose the directory (just a text input box) I post this back to the same app:

<form action="tedit.php" method="POST">
<div style="width:30em;">
<label for="directory">Directory to Search</label>
<input type="text" name="directory" id="directory" value=""/>
<div style="clear:both;">
<input type="submit" name="submitButton" id="submitButton" value="Submit">
</div>
</div> 
</form>

 

and when I process the post, I look at $_POST["submitButton"] and $_POST["directory"].

 

However, as is the case now, when the directory is nonexistent, I cannot figure out how to get rid of this data. I've tried unset() and $_POST["directory"]=""; but neither seems to work.

 

RON

The problem occurs because the recorded information in the browser's history for the URL is a form submission. When you navigate back to that URL or refresh the page the browser attempts to perform the action it has recored for that URL. There are two things you can do to fix this -

 

1) After you have successfully processed the form submission, redirect to the same URL. This will cause a GET request for that URL to be recored in the browser's history and it won't resubmit the form data when you navigate back to that URL.

 

2) Store a value in a session variable that indicates that the form has been processed and skip the form processing code as long as that session variable is set.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.