Mark Feller wrote:
> What are best practices to check to see if a .php script is called for the
> first time versus a user hitting a refresh button on their browser?
>
> I am playing around with a PHP front-end to a database. If the user
> enters values in a form (form.html), hits submit, the PHP script
> (insert.php) puts
> the submitted fields into the database as intended. insert.php displays a
> success message if successful or an error message otherwise. If the user
> hits the brower refresh button while at insert.php, the data is
> re-entered, and I end up with a duplicate entry in the database.
>
> This is the default behavior of Opera. IE prompts if I want to resend the
> data vs. not doing anything. If the data is resent, then the duplicate
> entry happens. I need to guard against this either way.
>
> Thanks for your help.
as Chuck mentioned redirect the user after successful submission to the
database. ( perhaps the db action should not be in a page delivered to the
user, but a separate script, you can set the script to run in the action
attribute of the form element )
G
--
http://www.kolumbus.fi/bob.smith
Received on Mon Oct 17 21:08:29 2005