martes, 24 de noviembre de 2009

Prevenir en php el insert duplicado

$c=OCILogon("scott", "tiger", "orcl");
if ( ! $c ) {
echo "Unable to connect: " . var_dump( OCIError() );
die();
}
$mydupcheck = "select * from personTable where firstname = $_POST[firstname] and lastname = $_POST[lastname] and emailaddress = $_POST[emailaddress]";

if($mydupcheck)
{
echo "Duplicate entry";
}
else
{
$s = OCIParse($c, "INSERT INTO personTable (firstname,lastname,emailaddress) VALUES ($_POST[firstname],'$_POST[lastname]','$_POST[emailaddress]'");
OCIExecute($s, OCI_DEFAULT);
echo "Record successfully entered";
}
?>

No hay comentarios: