[thelist] Question from Web designer

Hassan Schroeder hassan at webtuitive.com
Sun Mar 19 12:28:04 CST 2006


Robert Vreeland wrote:

> Although I am uncertain of the specifics in regards to dreamweaver, during
> your server side validation of the form you would check for existing records
> using the supplied email address. Then, if you found that email address
> already exists in the database you could output a pretty page telling the
> user. Basically, you want to ensure the 'validness' of your data before
> inputting it into the database rather then trying to rely on a thrown error
> from the database.

?! I have to disagree; why bother with two database operations
when one will do?

Let the various pieces do what they do best. A unique index on the
email address field will cause the database to return an error on
duplicate; catch the error and return an appropriate error page.

Most of the time the insert will succeed, anyway, in which case the
query would have been wasted time. And unless done as a transaction,
another process could do an insert *after* your query but *before*
your insert -- and you're back to having a duplicate field.

Proactively building in good exception handling will keep you from
ever exposing end users to raw error messages, regardless of the
technology in use. And that's a very good thing.

IMHO :-)
-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com
                opinion: webtuitive.blogspot.com
				
                          dream.  code.





More information about the thelist mailing list