I'm trying to make my registration avoid entering the same information more than once, the registration occurs from a modal like this below:
Afterfillingintheinformation,thedataissubmittedtoanAJAX,likethisonebelow:
functionadd_ionix(idOcorrencia,idTipoIonix,ionix,sas,idUsuario){$.ajax({url:"add_ionix.php",
type: "POST",
data: {
id_ocorrencia: idOcorrencia,
id_tipo_ionix: idTipoIonix,
ionix: ionix,
sas: sas,
id_usuario: idUsuario,
}
}).done(function(data){
//$("#formIonixAjax").html(data);
alert("Ionix adicionado com sucesso!");
$("#txt_ionix_preventivo").val("");
$("#txt_ionix_ocorrencia").val("");
$("#txt_sas").val("");
});
}
It works perfect to pass the data, but at the time of inserting, I am trying to bar the same register more than once, when I click Add to Modal if it closes and does not register, one hour change the script and register, but is not validating the "Existing Registration" message, could anyone help me with the example below:
<?php
include_once("config/conexao.php");
$idocorrencia = $_POST['id_ocorrencia'];
$idtipoionix = $_POST['id_tipo_ionix'];
$ionix = $_POST['ionix'];
$sas = $_POST['sas'];
$idusuario = $_POST['id_usuario'];
//$consulta = ("[LISTA].[SP_IONIX]);
$consulta = mssql_query("SELECT * FROM TBL_IONIX WHERE IONIX = '"$ionix"' OR SAS = '"$sas"' ");
$resultado = mssql_num_rows($consulta);
if($resultado >= 1){
echo "<script type=\"text/javascript\">alert(\"Este registro já existe\");</script>";
}else{
$sql = mssql_query("[INSERIR].[SP_IONIX] $idocorrencia, $idtipoionix ,$ionix,$sas, $idusuario");
}
?>
I do not understand why you should not fall under IF conditions, thank you in advance