RE: Clear POST variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I agree.  I always redirect my users to a "GET" page after a successful
posting so that they can't click the browser's "RELOAD" button to cause
a second posting.  I have used this technique in dozens of PHP
applications with hundreds of users, and it really cuts down on
duplicate entries.

On the "POST" page I usually add something to the session variables that
causes the user to see a "Your changes have been saved" type message on
the "GET" page that they're redirected to.

Tim Gustafson
MEI Technology Consulting, Inc
tjg@xxxxxxxxxxx
(516) 379-0001 Office
(516) 908-4185 Fax
http://www.meitech.com/ 



-----Original Message-----
From: John Wells [mailto:wellsdjohn@xxxxxxxxx]
Sent: Thursday, February 16, 2006 10:15 AM
To: php list
Subject: Re:  Clear POST variables


I'm curious to hear what others say, but I tend to build into my
application flow a header("Location: someurl") redirect after a form
submission.  It's just as if you were to include("somefile") the
resulting page, but by using header() you are moving the user away
from the action so that this sort of thing won't happen.  In my
experience it also helps with a user's tendency to use the back
button--which is not "wrong", it can just get in the way of rich
applications.

Cheers,
John


On 2/16/06, Mike Tuller <php@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> 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
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Attachment: smime.p7s
Description: S/MIME cryptographic signature


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux