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