Hope you'll forgive the duplicate post but the list seems to be hopping today (unlike the friday afternoon I sent the original query)... since everyone seems to be awake today I thought I'd try it again:
Sorry about that; I hate to keep my employers waiting. BTW, I haven't received my paycheck this month. ;)
1) A user submits a form containing about a hundred form fields which PHP needs to insert into a MySQL table.
2) MySQL is busy doing a lengthy SELECT for someone else, so the user's
browser hangs until the SELECT is done.
Okay, first of all, fix this "lengthy" select or whatever other slowdowns there are in your scripts.
3) The user gets tired of waiting and hits submit again while his browser is
4) When the long SELECT finishes, two PHP threads kick off (I'm assuming),
the user's original submit and his second, resulting in duplicate INSERT's
Easy way is to set a session variable when they submit a form flagging the form as submitted at time X. If it's been less than X seconds since the last time the form was submitted, then deny the re-submission.
Other method would be to supply a unique id to the form in a hidden element. When the form is submitted, put that variable in the session. If the form is submitted, the value is already in the session, so you know this is a duplicate entry.
What problems do the duplicate entries cause? You may be able to handle this at the database level with a UNIQUE restraint on your column.
-- ---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php