Refresh button

Refresh button

am 15.10.2007 17:14:52 von coder

I have what is probably a simple question. In a form I get the variables
with $_POST and then enter an insert into a database. After doing this, I
set the variable to an empty string. The form displays this empty string.
So far, so good.

If the user now hits the refresh button on the browser, the value of the
variable stays at the old value, not the empty string, so it passes the test
for not empty and another entry is inserted into the database.

How can I prevent this from happening?

Re: Refresh button

am 15.10.2007 17:20:34 von zeldorblat

On Oct 15, 11:14 am, "coder" wrote:
> I have what is probably a simple question. In a form I get the variables
> with $_POST and then enter an insert into a database. After doing this, I
> set the variable to an empty string. The form displays this empty string.
> So far, so good.
>
> If the user now hits the refresh button on the browser, the value of the
> variable stays at the old value, not the empty string, so it passes the test
> for not empty and another entry is inserted into the database.
>
> How can I prevent this from happening?

This question has been asked and answered in this newsgroup so many
times (probably about once per week). It shouldn't be hard to find
the answer with a little bit of searching.

Re: Refresh button

am 15.10.2007 17:59:12 von coder

"ZeldorBlat" wrote in message
news:1192461634.392862.14190@i13g2000prf.googlegroups.com...
> On Oct 15, 11:14 am, "coder" wrote:
>> I have what is probably a simple question. In a form I get the variables
>> with $_POST and then enter an insert into a database. After doing this,
>> I
>> set the variable to an empty string. The form displays this empty
>> string.
>> So far, so good.
>>
>> If the user now hits the refresh button on the browser, the value of the
>> variable stays at the old value, not the empty string, so it passes the
>> test
>> for not empty and another entry is inserted into the database.
>>
>> How can I prevent this from happening?
>
> This question has been asked and answered in this newsgroup so many
> times (probably about once per week). It shouldn't be hard to find
> the answer with a little bit of searching.

You are correct. I searched and it was as simple as adding a header line
back to the same page. That flushed the post values. Sorry.