RE: [PHP] Forms and destroying values
| From: | Beauford | Date: | Fri, 12 Jan 2007 20:13:26 +0000 |
| Subject: | RE: [PHP] Forms and destroying values | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-247015@lists.php.net to get a copy of this message | ||
Thanks, a little confusing there. You would think though that once the info
is transmitted by the browser it would be forgotten by the browser. Anyway,
I do have a work around, and since PHP can't do anything about what the
browser does, this will have to suffice.
Thanks all.
> -----Original Message-----
> From: Stut [mailto:stuttle@gmail.com]
> Sent: January 12, 2007 11:38 AM
> To: Beauford
> Cc: 'PHP'
> Subject: Re: [PHP] Forms and destroying values
>
> Beauford wrote:
> > 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.
> >
>
> You need to get it clear in your head when PHP is sending
> data to the client and when it is not. Your assumption is
> basically that the data in $_POST is actually *connected* to
> the form displayed in the browser.
> This is not the case. When you change the contents of $_POST
> it has no effect on what the browser displays or uses since
> it's not actually sent to the browser unless you specifically
> output it in the form of a, erm, form.
>
> When the user hits refresh, or uses the back button it is up
> to the browser what it does. In the case of refresh, if the
> page being refreshed was created in response to a form being
> submitted the browser will ask the user if they want to
> resubmit the data. When using the back button the browser
> will usually use its cached copy of the page rather than
> hitting the server again.
>
> Hope that makes it clearer.
>
> -Stut
>
> >> -----Original Message-----
> >> From: Satyam [mailto:Satyam@satyam.com.ar]
> >> Sent: January 12, 2007 8:21 AM
> >> To: Beauford; PHP
> >> Subject: Re: [PHP] 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@netscan.ca>
> >> To: "PHP" <php-general@lists.php.net>
> >> Sent: Friday, January 12, 2007 9:27 AM
> >> Subject: [PHP] 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
> >>
> >>
> >>
> >>
> >
> >
>
>
>