How do I check the User Name so username isn't already taken

My conection file "db_con.php"
<?php
$db_username = "root";
$db_password = "submit";
$db_hostname = "localhost";

$dbh = mysql_connect($db_hostname, $db_username, $db_password)
or die("Unable to connect to MySQL");
print "Connected to MySQL<br>";
?>

my test.php file

// Check User Name so username isn't already taken

please help me fix this code.

mssql_query = "SELECT users FROM login_db WHERE username = 'higate'";
$result = mssql_query($query);
echo $result;

if ($totalRows_Recordset != 1) {
die('Sorry, the username: <strong>'.$_POST['username'].'</strong> is already taken, please pick another one.');
}

    looks good so far... just use this before you test the if condition at the end of what you gave me.

    $totalRows_Recordset = mysql_num_rows($result);
    

      please help me wit this
      is seams to beright but it not.

        Use something like this

        $sql_username_check = mysql_query("SELECT username FROM login_db WHERE username='$username'"); 
        $username_check = mysql_num_rows($sql_username_check);
        if ($username_check  > 0) {
        echo "The user name you have selected has already been used by another member.Please choose a different user name";
        unset ($username);
        }
        

        HTH

          Write a Reply...