Page 1 of 1

clearing $_POST variables

Posted: Tue Jan 07, 2003 2:08 pm
by daven
I am using $_POST variables in some of my scripts, and sending the info to a database. However, if a user reloads the page, the data is sent again (resulting in repeat entries).

Is there any way to destroy $_POST variables after use? Using unset() does not work, since reloading the page will re-initialize $_POST variables. I need to destroy the variable entirely (ie: use $_POST['id'], then get rid of it so subsequent calls will not work).

Posted: Tue Jan 07, 2003 2:25 pm
by oldtimer
There must be but I just usually redirect them back to a certian page and make it go quick so they dont have a chance to do it. I never let it go more than 3 seconds. And alot of times only 1 second. However you could make a Thank you page and redirect all pages to that one with a 0 second delay as well.

Posted: Tue Jan 07, 2003 2:47 pm
by mydimension
i covered this in another topic but i can't seem to find it. when the user refreshes the page, the browser re-submits the POST variables to the server. (most browsers issue a warning about this.) so there is now way to erase them. you should do what oldtimer does, redirect to another page after you process the POST data.

Posted: Tue Jan 07, 2003 2:58 pm
by daven
Ah well. The workaround I have been using is just to do a header("Location: ".$_SERVER['PHP_SELF']). It works fine (gets rid of $_POST vars). I was just wondering if there was a call to destroy the vars directly.

Thanks guys.