Possible Duplicate:
insert contacts into database but does not want to duplicate already existing contact
what i intend to do is, check if a user's account is already stored in my database, redirect to another url else store his data in the database. following is the query i wrote. it is not working please suggest where i went wrong. thaks.
$result = mysql_query("SELECT * FROM centraluser where id = '$id'");
$row = mysql_fetch_row($result);
if($row) {
mysql_query("UPDATE central SET time = '$time' WHERE id = '$id'");
$url = "http://www.somesite.com";
echo '<script type="text/javascript"> alert("Sorry! you can't register twice.");</script>';
echo '<script type="text/javascript">top.location.href = "'.$url.'";</script>';die;exit;
}
else {
mysql_query("INSERT INTO centraluser VALUES ('$id','$name','$email','0','5000','0','0','$birthday','$time')");
echo('welcome new user');