I want to clear $POST variables after a successful submission of a form that has action="<?php echo $PHP_SELF?>", on clicking back the forms will be clear. I tried using unset($POST) after a successful submission, but the variables are still listed when I go back. Any suggestions?
clearing post variables after form submission
after successful transmission, just do
$_POST = "";
that should clear all values.
I just read, in another post, that $_POST is an array. so there might be some array function that removes/clears all its values.
hmm, that still doesn't quite work...I don't think the problem is clearing the variables, but how the page is called.
I don't think that would work, since the browsers cache is very persistent. The values in question wouldn't be $_POST values, but text in html forms.
And it's the previous page (with the form) that needs to be looked at, not the submitscript.
If you try to set some no-cache headers in the script with the form:
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
That might help, but I doubt it The browsers, and especially msie for win2000, is VERY fond of their cached pages, and reluctant to let the data go...
knutm
They only let the data go when it's really inconvenient for the user...
knutm :p