Re: Refresh (F5) adds another SQL record.

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

 



On Tue, May 17, 2005 2:24 pm, Robert Meyer said:
> Hello,
>
> Scenario:
> 1) User is presented a blank form.

with an MD5 hash which is stored in the database as "fresh"

> 2) User fills in form.
> 3) User submits form.
> 4) Record is added to database.

That particular MD5 has is marked as "used"

> 5) Back to 1).
> All is fine to here.
> 6) User clicks refresh.
> 7) Another record is added, same data except auto-increment field.
> How do I prevent these last two steps, or at least prevent a record
> from being added when refresh is clicked?

The used MD5 hash tells you they are re-submitting the exact same form.

Now, if the real problem is that the user has a fresh new form, and fills
in the same data again by hand, then there are only two possibilities:

1. In the real world, they actually NEED two of the "same" thing in the
database, and your application should allow it.

2. In the real world, users are likely to lose track of where they are in
their data entry, and you need to provide them the context to help avoid
that. When you go back to 1) present a message like "added blah blah blah"
at the top of the screen.  Now they *KNOW* they just did blah blah blah,
and can move on to blah blah bleh.  Data entry is a sucky job.  Make it
nicer for them, eh?  You STILL need to code for the dual entry, and do
something intelligent when they mess up, but you can improve efficiency
and decrease errors (where 2 not-quite-the-same-but-really-are-the-same
entries pass your tests) if you make your application nicer to the user.

-- 
Like Music?
http://l-i-e.com/artists.htm

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