[GLLUG] [ot]MySQL/PHP

Ben Pfaff blp@cs.stanford.edu
27 Feb 2002 18:56:59 -0800


Mike Szumlinski <szumlins@msu.edu> writes:

> Okay, so I've built a form that works fine and posts data to a mysql
> database correctly. Now I want to add a little validation to make sure that
> no one has put the same info in twice. I'd like to use a non auto increment,
> non primary key value (an e-mail address actually) as the validator, so if
> someone tried to use the form twice with the same e-mail address, they
> wouldn't be able to post the second time and the page would say something
> like "you have already registered"

I would just make the email column UNIQUE in the database schema,
so that an attempt to insert a duplicate row would be rejected
automatically by the database server.
-- 
<blp@cs.stanford.edu> <pfaffben@msu.edu> <pfaffben@debian.org> <blp@gnu.org>
Stanford Ph.D. Student - MSU Alumnus - Debian Maintainer - GNU Developer
Personal webpage: http://www.msu.edu/~pfaffben