[thelist] Seeking JS Solution for Double Form Submission????

rudy r937 at interlog.com
Mon Jul 16 17:20:13 CDT 2001


> if you absolutely must prevent multiple submissions,
> then you must also implement a server-side solution.

do this with a database uniqueness constraint

this puts the onus on the developer to come up with friendly error messages
(no, not like the "friendly" 404 message you get in internet explorer), but
the nice thing is, it usually doesn't take a lot of effort

there are two ways you can do it

the first way is what i call the programmer's approach -- run a query, see
if the thing you're about to insert is already there, and if it is, issue
an error message that the entry cannot be inserted and skip the insert
command, otherwise, go ahead with the insert command

the other way is the what i call the data architect's approach -- just go
right ahead and issue the insert command in all cases and let the database
tell you when it has prevented a duplicate from being inserted, in which
case you turn around and issue an error message that the entry was not
inserted

see the difference?

let's say that out of 100 times, you experience an attempted duplication 5
times

in the programmer's approach, you are doing 100 queries, which, granted,
are very quick, plus 95 inserts, which are slower

in the data architect's approach, you are doing 100 inserts of which 5 will
come back real quick

now see the difference?   ;o)


the only difference that checking for duplication on the client side will
make is that it can cut down your attempt rate from 5 per 100 to something
less -- but if your database needs to maintain integrity, then you have to
do the check again on the server, so the less effort the client side is to
implement, the better




rudy







More information about the thelist mailing list