Re: question about M. Lemos's HTML forms generation and validation
| From: | Tom Rogers | Date: | Fri, 26 Mar 2004 01:50:02 +0000 |
| Subject: | Re: question about M. Lemos's HTML forms generation and validation | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-181530@lists.php.net to get a copy of this message | ||
Hi,
Friday, March 26, 2004, 11:19:51 AM, you wrote:
dz> Hello,
dz> I'm creating registration service with this great form script for
dz> creating forms within Smarty.
dz> Question is how can I validate 'username' against allready registered
dz> users in MySQL so that someone cannot register him self if there is
dz> another user with that username.
dz> TNX!
what I do is make that column unique and then check for mysql error
like this:
$error = '';
if($success){
//output success message
else{
$errnum = mysql_errno();
switch($errnum){
case 1062:
$error .= 'This email address is already registered.<br>';
break;
default:
$error .= mysql_error().' '.mysql_errno().'<br>';
break;
}
}
--
regards,
Tom