Thread: User reloads inert script...

User reloads inert script...

From
"Christian Marschalek"
Date:
Hey there:)

What would you do?

Situation: you have a script doing some HTML formular data processing,
some selects and inserts in a transaction and some html output.

When the script is cancled on the client side. By normal PHP will cancel
the script it self (which can be prevented). Now hopefully the
transaction will be rolled back on PostgreSQLs side. Everything fine...

But what If the user reloads the page? Then the whole process will be
done twice... How would you prevent that?

Tia! Chris



Re: User reloads inert script...

From
Grant
Date:
Well hopefully the error can easily be seen if it's a duplicate entry in
a table or something along those lines, and your IE will prompt you
before reposting form data. However, you can set a session variable that
identifies that the "process" you are performing has already been
completed. So after the insert is complete it will set the session
variable as 1, then if they press repost the variable exists and the
data will not be inserted again, and when the user clicks on the correct
menu to prompt to insert "new" data into the database, the variable will
be unset, so the insert can pass through, and then set again to stop
futher duplicate posts of the same data. Hope this helps.

On Thu, 10 May 2001, Christian Marschalek wrote:

> Hey there:)
>
> What would you do?
>
> Situation: you have a script doing some HTML formular data processing,
> some selects and inserts in a transaction and some html output.
>
> When the script is cancled on the client side. By normal PHP will cancel
> the script it self (which can be prevented). Now hopefully the
> transaction will be rolled back on PostgreSQLs side. Everything fine...
>
> But what If the user reloads the page? Then the whole process will be
> done twice... How would you prevent that?
>
> Tia! Chris
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>


RE: User reloads inert script...

From
Maxim Maletsky
Date:
Netscape does it alllll the time.

For Example: user's filling in the form, then tries to resize it's browser
window to get a better visibility, Netscape will reload.

The best way to prevent this is by having a unique values, and before
inserting checking for duplicates. The worth way to fix it is by having more
then one form and/or some session variables as was advised before.\

Cheers,
Maxim Maletsky


-----Original Message-----
From: Grant [mailto:grant@conprojan.com.au]
Sent: Monday, May 14, 2001 9:35 AM
To: pgsql-php@postgresql.org
Subject: Re: [PHP] User reloads inert script...


Well hopefully the error can easily be seen if it's a duplicate entry in
a table or something along those lines, and your IE will prompt you
before reposting form data. However, you can set a session variable that
identifies that the "process" you are performing has already been
completed. So after the insert is complete it will set the session
variable as 1, then if they press repost the variable exists and the
data will not be inserted again, and when the user clicks on the correct
menu to prompt to insert "new" data into the database, the variable will
be unset, so the insert can pass through, and then set again to stop
futher duplicate posts of the same data. Hope this helps.

On Thu, 10 May 2001, Christian Marschalek wrote:

> Hey there:)
>
> What would you do?
>
> Situation: you have a script doing some HTML formular data processing,
> some selects and inserts in a transaction and some html output.
>
> When the script is cancled on the client side. By normal PHP will cancel
> the script it self (which can be prevented). Now hopefully the
> transaction will be rolled back on PostgreSQLs side. Everything fine...
>
> But what If the user reloads the page? Then the whole process will be
> done twice... How would you prevent that?
>
> Tia! Chris
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org