use this command

$res=mysql_query("select * from table name where value1= $_post['value1']");

if (mysql_num_rows($res)>0)

{
$ans="value already exist";

}
else
{
$ans="....insert command...";
}

kishou commented: Helped me alot with mysql! +1