1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

username validation in php

Discussion in 'PHP' started by pinku, Apr 3, 2008.

  1. pinku

    pinku New Member

    Joined:
    Mar 27, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hi,

    lI am new to php coding. I'd need some help...im setting up a username/password system and need to be able to check whether a new username is unique. I have tired....can u help me?
     
  2. mufaddal zirapurwala

    mufaddal zirapurwala New Member

    Joined:
    Apr 17, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    U can do this by just a select query here is the solution

    $query = "SELECT * FROM UserTable WHERE username=".$_Post['username'];
    $Con = mysql_query($query, $connection) or die(mysql_error());
    $row = mysql_fetch_assoc($Con);
    $totalRows = mysql_num_rows($Con);

    if($totalRows>0)
    {
    echo 'Username exist';
    }
    else
    {
    echo 'Unique Username';
    }

    hope this code can help
     

Share This Page