The code does not work does not throw me any kind of error I do not know what is wrong I hope you can help me. The validation does not work with js, nor does it show me the echo of the connection
function valida(){
var cod,nom,rut,fon,act,ema,dir;
cod=document.getElementById("cod").value;
nom=document.getElementById("nom").value;
rut=document.getElementById("rut").value;
fon=document.getElementById("fon").value;
act=document.getElementById("act").value;
ema=document.getElementById("email").value;
dir=document.getElementById("dire").value;
if(cod=""){
alert("El campo Codigo auxiliar esta vacio");
return false;
}else if(nom=""){
alert("El campo NOMBRE esta vacio");
return false;
}else if(rut=""){
alert("Debe ingresar el rut");
return false;
}else if(fon=""){
alert("Debe ingresar el número de telefono");
return false;
}else if(act=""){
alert("El campo ACTIVIDAD esta vacio");
return false;
}else if(ema=""){
alert("Debe ingresar un email");
return false;
}else if(dir=""){
alert("Debe ingresar una direccion");
return false;
}
formato_email=/\w+@+\w+\.+[a-z]/;
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
</head>
<body>
</body>
</html>
<?php
require 'conexion.php';
cone();
if($_POST['btn_ingresar']){
$cod = $_POST['cod'];
$nombre = $_POST['nom'];
$rut = $_POST['rut'];
$act = $_POST['act'];
$fono = $_POST['fon'];
$correo=$_POST['email'];
$direcion=$_POST['dire'];
$comprobar= sqlsrv_qery($con,"SELECT CodAux FROM softland.CWTAUXI WHERE CodAux=$cod");
if($comprobar==true){
echo"El cliente ya esta registrado ";
echo "<br>";
echo "<br>";
}else{
$insertarc=sqlsrv_qery($con,"Insert Into xx ( CodAux,NomAux,NoFAux, RutAux,ActAux,GirAux, PaiAux,Region, CiuAux,Comaux,Provaux, DirAux,DirNum,DirDpto, CodPostal,FonAux1,FonAux2, FonAux3,CodAreaFon, AnexoFon,FaxAux1,FaxAux2, CodAreaFax,
ClaCli, ClaPro, ClaEmp, ClaSoc,ClaDis,ClaOtr, Casilla,Email, WebSite, Bloqueado, BloqueadoPro, Notas , EsReceptorDTE ,EMailDTE, CtaCliente, CtaCliMonExt) VALUES ( '$cod', '$nom', Null, '$rut', 'S', Null, Null, Null , Null, Null, Null, Null, Null, Null, Null, '$fono', ' ', ' ', 0, 0 , ' ', ' ', 0, 'S', 'N', 'N', 'N', 'N', 'N', Null, '$correo', Null, 'N', 'N', Null , 'N', Null , NULL, NULL)");
if(!$ejecutar){
printf("Error en ejecución: %s\n", $con->error);
echo "0<br>";
echo "<br>";echo "<br>";
echo "<br>";
}else{
echo "El vendedor de registro exitosamente en la BD ";
echo "<br>";
echo "<br>";
}
}
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Registrar clientes</title>
<link rel="stylesheet" href="css/style.css">
<script src="js/validar.js"></script>
</head>
<body>
<form action="procesos.php" method="post" onSubmit="return valida();">
<div class="logo">
<img src="imagenes/logo.png" width="90%" height="10%">
</div>
<h2>Ingresar clientes</h2>
<div class="input_style">
<input type="text" name="cod" placeholder="Codigo auxiliar">
<input type="text" name="nom" placeholder="Nombre">
<input type="text" name="rut" placeholder="Rut">
<input type="text" name="act" placeholder="Activo">
<input type="text" name="fon" placeholder="Telofono">
<input type="text" name="em" placeholder="Email">
<input type="text" name="dire" placeholder="Direccion">
<input type="submit" value="Guardar" id="btn_ingresar" class="btn">
</div>
</form>
</body>
</html>