I have 2 forms, one per ajax and the other normal php. both forms are running, but when I run the php form without ajax it returns me the php form errors with ajax.
PHP With ajax
if ($_SERVER["REQUEST_METHOD"] == "POST") {
PHP Without ajax
if (isset($_POST['Btnlk'])){
If the conflict is not there I'll put all the code.
Form Code with ajax
<form class="form1" method="POST" enctype="multipart/form-data">
<div id="ressult_log_succes"></div>
<div id="ressult_log_error"></div>
<p>E-mail</p>
<input type="text" name="Email_user" placeholder="Informe seu E-mail">
<p>Senha</p>
<input type="password" name="Senha_user" placeholder="Informe a sua senha">
<input type="submit" id="Bot_login" name="Logar_sn" value="Logar">
</form>
<script>
$(function(){
$(".form1").submit(function(event){
event.preventDefault();
var formDados = $(".form1").serialize();
$.ajax({
url:"/complement-of-archive/ConsultaLoginUser.php",
type:"POST",
data:formDados,
cache:false,
processData:false,
success:function(data){
$("#ressult_log_succes").html(data);
},
error:function(data){
$("#ressult_log_error").html(data);
},
dataType:"html"
});
return false;
});
});
</script>
My form without ajax
<form class="form2" method="POST" enctype="multipart/form-data">
<input type="hidden" name="ID_Pagina_LK_DL" value="2">
<input type="text" name="Usuario_LK_DL" value="" placeholder="Informe seu nome">
<input type="submit" name="Btnlk" value="1">
</form>
<?php
require_once('SysLKDLe.php');
?>
php from my non-ajax form
<?php
if (isset($_POST['Btnlk']) && $_POST['Btnlk'] == "1") {
$LK_DL = 1;
$ID_Pagina_LK_DL = $_POST['ID_Pagina_LK_DL'];
$ID_Usuario_LK_DL = $_POST['Usuario_LK_DL'];
if ($LK_DL != 1) {
}
else{
$SQL_LK_DL = mysqli_query($conex,"INSERT INTO Banco_lk (LK_DL, Nome_LK_DL, IDUser_LK_DL) VALUES ('$LK_DL', '$ID_Pagina_LK_DL', '$ID_Usuario_LK_DL')");
}
}
?>