Log in

View Full Version : simple SQL validation



d-machine
06-13-2008, 05:04 PM
Hi

I have a signup form for a my site, it includes username, password and email. I wanted to check that if the username or the email is already exist in my DB so It will write "this username or email is already in use"

otherwise it should sign him to the site.

I succeeded on making the signinig part, but not the validation.

Can someone help me? :confused:

Thanks

boogyman
06-13-2008, 05:23 PM
just do a selection query for the username / email and if it returns a value then its already in use



if(mysql_query("SELECT username, email FROM Users WHERE username='_something_' OR email='_something_'"))
{
$error = "Username already in use";
}

d-machine
06-14-2008, 05:15 AM
just do a selection query for the username / email and if it returns a value then its already in use



if(mysql_query("SELECT username, email FROM Users WHERE username='_something_' OR email='_something_'"))
{
$error = "Username already in use";
}


Hi thank you for your help but I was needed it in SQL, cause I'm using ASP and Access.