Re: Forms and destroying values

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

 



As many have already replied to your question, what happens is that upon a refresh the browser is resending the original post variables again.

The unset() does work, from the point of the unset() to the end of the script (when all variables except for session variables are unset), PHP will have completely forgotten about those values. But that does not affect the browser at all.

On a refresh the browser will send the information again, unless it is tricked via a redirection command to believe the URL used for the post is obsolete. Then, what the browser will do is to remember the URL it was redirected to and drop the 'obsolete' URL so, when the user does a refresh, the browser will be smart enough to go to the 'updated' (the redirected-to) URL instead of the original 'obsolete' one and thus will get the confirmation page again, but without passing through the database transaction.

Satyam



----- Original Message ----- From: "Beauford" <phpuser@xxxxxxxxxx>
To: "'PHP'" <php-general@xxxxxxxxxxxxx>
Sent: Friday, January 12, 2007 5:23 PM
Subject: RE:  Forms and destroying values



So the answer is, there is no way to destroy the values. Question then, what
is unset() used for as it doesn't seem to do anything? With a language as
good as PHP I though there would be some way to do this. I have got a
workaround, but that's exactly what it is - a work around. I am also still
confused as to why giving them a null value doesn't work.

Thanks to all.


-----Original Message-----
From: Satyam [mailto:Satyam@xxxxxxxxxxxxx]
Sent: January 12, 2007 8:21 AM
To: Beauford; PHP
Subject: Re:  Forms and destroying values

This issue comes over and over again.  The trick, as I
learned from this list, is to send a redirect to the browser
to a confirmation page, so the browser remembers the page
redirected to and completely ignores the page that made the
redirection so that neither a refresh nor going back to it
can repeat the operation.

So, if the database update has been succesful, use the
header() function to send a 'location' header along with
enough arguments in the URL to display a significant
confirmation message  but make sure that it is different from
the URL that makes the database update.   It will be this
address, not the
post that made the database update, that the browser will remember.

Satyam



----- Original Message -----
From: "Beauford" <phpuser@xxxxxxxxxx>
To: "PHP" <php-general@xxxxxxxxxxxxx>
Sent: Friday, January 12, 2007 9:27 AM
Subject:  Forms and destroying values


> Hi,
>
> How do I stop contents of a form from being readded to the
database if the
> user hits the refresh button on their browser.
>
> I have tried to unset/destroy the variables in several
different ways, but
> it still does it.
>
> After the info is written I unset the variables by using
unset($var1,
> $var2,
> $etc). I have also tried unset($_POST['var1'], $_POST['var2'],
> $_POST['etc']). I even got deperate and tried $var = ""; or
$_POST['var']
> =
> "";
>
> What do I need to do to get rid of these values???
Obviously I am missing
> something.
>
> Any help is appreciated.
>
> 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




--
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


[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