RE: [PHP] Clear POST variables
| From: | Dan Parry | Date: | Thu, 16 Feb 2006 15:14:08 +0000 |
| Subject: | RE: [PHP] Clear POST variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-230556@lists.php.net to get a copy of this message | ||
Submit the data to a page that just inserts it into the DB (validating it
first, natch) then do a header(location) to the thank you (or whatever) page
This also fixes 'page expired' warnings
HTH
Dan
-----Original Message-----
From: Mike Tuller [mailto:php@discovercommunityed.com]
Sent: 16 February 2006 15:07
To: php list
Subject: [PHP] Clear POST variables
I have a page that submits form information into a database, and all is
good, but someone testing the page pointed out something to me that I
didn't notice. I have a form that sends you to another page that submits
the data into a database. If you refresh the page, the information is
submitted again. Here is what I have.
$name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zipcode = $_POST['zipcode'];
$phone = $_POST['phone'];
$notes = $_POST['notes'];
$query = "insert into Locations
(name, address, city, loc_state,
main_phone, zipcode, notes)
values
('$name', '$address', '$city',
'$state', '$phone', '$zipcode',
'$notes')";
mysql_query($query, $link) or die
(mysql_error());
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.
Thanks.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php