There is a simple way of preventing duplicate inserts that doesn't rely
on generating a unique form id.
This topic has been discussed many times at Photo.net and now
Openacs.org. OpenACS has a double click protection, but I think it still
relies on cooperation between the form and the form processing page.
What you really want is to prevent duplicate data so here is the outline
of a one page (the form processing page) solution that guarantees you
never insert duplicate data.

0. create hash_table ( hash_value varchar primary key, time timestamp
default now() );
1. set hash_value [hash_procedure [join $field_1 $field_2 ... $field_n
$other_data]]
2. if {[catch { insert hash_value into hash_table} err] } { sorry }
3. insert fields into your_table

This method should work with multiple form processing pages, assuming
all use the same combination of fields to generate the hash value.
This is a general solution that also solves the problem of someone
needing to insert lots of similar data. They insert, backup and change a
field or two, and resubmit the form.
In the case where all data could be the same for multiple rows, you
might put a time limit on the insert of duplicate data, just to prevent
accidental inserts.

--Tom Jackson


Bas Scheffers wrote:

I thought that might be your reasoning, but expiring the page will achieve
the exact oposite of that! Backing up to an expired page will make IE
either ask if you want to resubmit your data ("a box with yes and no,
ehrm, let's click yes!") or worse, impicitely do it for you.

The best ways to prevent resubmitting is to see if it already has been
done by having some special ID on the page and in the database, which you
check against before inserting/updating/whatever and throw an error
yourself, or after the submit, do a redirect to another page. Downside of
that is that if the redirect doesn't load for whaterver reason, the user
may use back and click submit on the form again. So maybe a combination of
the two is the safest way to go!

Bas.

oetjoen said:


Actually I want to prevent someone would be resubmitted the same data
more than once by using back button on internet browser. so I think its
better idea if I using the previous page has been expired.
Or anyone could give me any idea.




I. To remove yourself from this list:

Send a message to "[EMAIL PROTECTED]"  with the following text in
the BODY of your message:

signoff aolserver

II. For a complete list of listserv options please visit:

http://listserv.aol.com/

III. For more AOLserver information please visit:

http://www.aolserver.com/






I. To remove yourself from this list:

Send a message to "[EMAIL PROTECTED]"  with the following text in
the BODY of your message:

signoff aolserver

II. For a complete list of listserv options please visit:

http://listserv.aol.com/

III. For more AOLserver information please visit:

http://www.aolserver.com/

Reply via email to