Assuming that the username is unique in the system, run a query and check the result / rows returned.
If this is mysql - the following should work:
$result=mysql_query($query);
$rows = mysql_num_rows($result);
if ((!$result) || ($rows<1)) {
/ User does not exist /
}
else {
/ Username returned /
}
Hope it helps.
-m.