Two methods come to mind:
Either do a select on the username to see if it exists before trying to 
insert it,  or, if the errstr for the message about a duplicate entry is 
unique enough, just look at the errstr, and if it tells you that the name 
already exists, issue an appropriate message to the user.





Will <[EMAIL PROTECTED]>
02/07/2003 10:57 AM

 
        To:     DBI Users <[EMAIL PROTECTED]>
        cc: 
        Subject:        Can DBI be used to validate input?


I am developing a registration area for a members site
that will interface with a MySQL DB users table, and I
ran into a problem.  Note that I am using DBI
as my DB Driver.

Suppose the user tries to register with a username
that has already been taken.  I need a way to kick
back an error message to them.  I tried setting the
username field in the usrs table to UNIQUE, so that
might help if someone tried to insert something
already taken... I was thinking that if MySQL kicks
back an error message, then DBI might be able to
recongize it in such a way that I could use the return
value... I dont know if that is completely feasible
though...  there may be other, better ways anyway...
so I'm all ears...

Thanks,

Will

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


Reply via email to