Re: Clear POST variables

From: Date: Thu, 16 Feb 2006 15:20:18 +0000
Subject: Re: Clear POST variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-230549@lists.php.net to get a copy of this message
How do I clear out the POST variables, or the variables that I have set from the POST variables, so that when the page is refreshed it will not resubmit. I have tried unset() and have tried to set it to and empty value, but it doesn't seem to work.
You can clear out POST by doing this: $_POST = array(); But that won't do anything in your case because every time the page is refreshed the form is resubmitted (and POST is repopulated). You need to find a way to ensure unique entries in the database. One option is to store a hidden, random value in the form, like a timestamp or the md5() of a random value. Then store this in the db, along with the other data. Put a unique index on that column so that the same random value cannot be inserted multiple times. (In other words, the form would need to be reloaded, then resubmitted for the data to go into the db.) HTH, Larry

« previous php.general (#230549) next »