Forum Moderators: coopster
I have a file with a form that call itself and processes the form info.
when my first subbmition is complete I am shown the form again.
If I hit the browser refresh it will add the same info again.... meaning it is keeping the last post in memory.
How can I clear the last post befor the form is shown again
<input type="reset" />- see here [w3.org] -
or you could try doing something like making a link to reset it:
echo '<a href="'.$_SERVER['REQUEST_URI'].'">reset</a>';
Is this what you mean?
If I hit the browser refresh it will add the same info again.... meaning it is keeping the last post in memory.How can I clear the last post befor the form is shown again
if you only don't want php to display the values submitted, just don't put the vars in your code, use
value=""instead.
To prevent this from happening, you could reload the page after you process the POST data, so you have a clean GET request. You can do that with Javascript in the onload event of the body.
I'm not sure if this is your problem, but hope this can help you.
form.php
<form method="post" action="post.php">
<input name="test" value="" />
<input type="submit" />
</form> post.php
<? /*
* process whatever you want here but don't make any output! *
*/
header("Location: http://host/form.php");
exit();
?> this is doing a redirect after submission. it won't need javascript and works with any browser. if this does not solve your problem, please describe more specific what you mean.
post.php puts the POST data in session and redirect:
$_SESSION["POSTDATA"] = $_POST ;
header("Location: [host...]
exit();
Then in form.php:
if(isset($_SESSION["POSTDATA"]))
{
$_POST = $_SESSION["POSTDATA"] ;
unset($_SESSION["POSTDATA"]) ;
}
Each page contains its own POST processing..
My code is more complexe than that but you have the general idea.