see if a field allready exists

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adixtopix
Forum Newbie
Posts: 17
Joined: Thu Jun 23, 2005 7:02 am

see if a field allready exists

Post by adixtopix »

okay, i am working with mysql now

my problem is this
a user makes an account on my site
i want to check if there is a user using that nickname allready


thencks guys
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

Code: Select all

$query = '
    select
      username
    from
      table_name
    where
      username = "$username"
';

$do_query = mysql_query($query) or die(mysql_error());

if (mysql_num_rows($do_query))
{
    die('username taken');
}
else
{
    //create user query
}
Post Reply