on vr, 07 feb 2003 18:54:25 GMT, Will wrote:
> Second, suppose they try 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...
I would not rely on an error-message from the database, but check for the
existence of a username myself, e.g. like such (untested):
my $username = param('username'); # from webform
my $dbusername = $dbh->selectrow_array(qq{
SELECT
username
FROM usertable
WHERE
username = ?
}, undef, $username);
if ($dbusername) {
# username already in the database
} else {
# username not yet in the database
}
--
felix
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]