Good morning: I am creating a file in php that connects to a localhost, what I need is to make it validate in the localhost that there are no duplicate records, the validation I have to do with the rfc (Mexican) since it is a unique value. I request your support since I'm just starting the race and I do not know php. Annex the code that I am using
<?php require_once('coneccion.php');
$nombre = $_POST["nombre"];
$apellidopaterno = $_POST["apellidopaterno"];
$apellidomaterno = $_POST["apellidomaterno"];
$fechanacimiento= $_POST["fechanacimiento"];
$rfc = $_POST["rfc"];
$q = "INSERT INTO persona (id, nombre, apellidopaterno, apellidomaterno, $fechanacimiento, rfc) ";
$q.= "VALUES(0,'".$nombre."','".$apellidopaterno."','".$apellidomaterno."','".$fechanacimiento."','".$rfc."')";
$r = mysqli_query($conn,$q);
if($r){
$response["success"] = 1;
} else{
$response["success"] = 0;
}
echo json_encode($response);
?>