i just did this myself as a matter of fact.
What you want to do is within the script, of course is connect to the database and then query it limiting the query to search for records that have the username. Then use an if statement to check and see if the username matches, if it does indeed match, then you could redirect them using the header() function.
here is an example-
mysql_select_db($DBName, $Link1);
$Query1 = "SELECT * from users where user = '$user'";
$Result1 = mysql_query($Query1, $Link1);
$Array1 = mysql_fetch_array($Result1);
$usercheck = $Array1["user"];
if ($usercheck == $user) {
header(Location:"htpp://www.someplace.com");
exit;
}
else
(put in the query and a second connection here to insert the record)
*** this is an extremely simplified version, and it is not necessarily secure though. You can use an include file and have a function defined there that does all this for you, and it will hide your logic from users- just be sure to put the include file outside of the root directory.
Hope this helped you out?