I have a form and the button is not generating any action I leave the code with which I am executing

0
<div align="center">
                <input align="center" name="EnviarInfo" class="btn btn-primary btn-block" type="submit" style="width: 50%" action='EnviarInfo' value="Asignar">
        </div>
    </form></center>

    <?

 if ($_POST[EnviarInfo])

 { 


    $link = mysqli_connect("localhost","pcomp","KneTPuxJ77f4YLNX", "xxxx");  
    $causa_falla = $_POST['causa_falla'];
    $c1 = $_POST['c1'];
    $c2 = $_POST['c2'];
    $c3 = $_POST['c3'];
    $c4 = $_POST['c4'];
    $c5 = $_POST['c5'];
   $date = date('Y-m-d H:i:s');
   $obs = $_POST['obs'];
   $par = $_POST['par'];

  $link = mysqli_connect("localhost","pcomp","KneTPuxJ77f4YLNX", "xxxx");  

  if ($_POST['estado'] == 'Rechazado'){
        $sql = "UPDATE 'avisos_auditados' set 'estado'='No es Falla' f_termino='$date' where id_aviso=$id_p";



    if(mysqli_query($link, $sql)){

                echo "<script>alert('Cambios realizados', 'Asignar CFN')</script>"; 

            } else{

                echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
            }

              $yourURL="ver_aviso_auditado.php?id=$aux";
              //echo ("<script>location.href='$yourURL'</script>");
            echo"<META HTTP-EQUIV='Refresh' CONTENT='0;url=$yourURL'/>"; 



    }
    else if ($_POST['estado'] == 'Aprobado'){

        if ($c1 == "" && $c2 == "" && $c3 == "" && $c4 == "" && $c5 == "" ) {

            echo "<script>alert('Debe ingresar una cuenta como minimo', 'Debe ingresar una cuenta')</script>";

        }else {

            $contadorCuentas = 0;

            if ($c1 == "" ) {

                $contadorCuentas = $contadorCuentas + 0;
            }else{

                $contadorCuentas = $contadorCuentas + 1;

            }

            if ($c2 == "" ) {

                $contadorCuentas = $contadorCuentas + 0;
            }else{

                $contadorCuentas = $contadorCuentas + 1;

            }

            if ($c3 == "" ) {

                $contadorCuentas = $contadorCuentas + 0;
            }else{

                $contadorCuentas = $contadorCuentas + 1;

            }

            if ($c4 == "" ) {

                $contadorCuentas = $contadorCuentas + 0;
            }else{

                $contadorCuentas = $contadorCuentas + 1;

            }

            if ($c5 == "" ) {

                $contadorCuentas = $contadorCuentas + 0;
            }else{

                $contadorCuentas = $contadorCuentas + 1;

            }

            $sql = "UPDATE avisos_auditados set estado='Es Falla', f_termino='$date' where id_aviso=$id_p";

            $sql2 = "INSERT INTO avisos (tipo_defecto, direccion, agencia, central, tipo_cable, cable, armario, cuenta1, cuenta2, cuenta3,cuenta4,cuenta5, fecha_ingreso, fecha_revisar_aviso, fecha_respuesta_aviso) 
                     VALUES ('$tipo_defecto','$direccion', '$agencia', '$central', '$central','$tipo_cable','$cable','$armario',cuenta1='$c1', cuenta2='$c2',cuenta3='$c3',cuenta4='$c4',cuenta5='$c5','$date','$date','$date')";

            if(mysqli_query($link, $sql) and mysqli_query($link, $sql2)){

                echo "<script>alert('Cambios realizados', 'Asignar CFN')</script>"; 

            } else{

                echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
            }
            try {
                echo $_POST[EnviarInfo];
            } catch (Exception $e) {
                echo "exepcion campturada:".$e->intl_get_error_message();

            }

              $yourURL="revisar_aviso_falla.php?id=$aux";
              //echo ("<script>location.href='$yourURL'</script>");
            echo"<META HTTP-EQUIV='Refresh' CONTENT='0;url=$yourURL'/>"; 

            }

    }


}


?>
    
asked by jeson 21.09.2018 в 20:22
source

1 answer

1

First of all I think you should see some videos on YouTube about SQL queries and their syntax, on the other hand your code has many faults including single quotes within single quotes, no quotes, connection to the unnecessarily duplicated databases etc ...

See how the correct sintaxys would be for SQL sentences

//tu html correctamente quedaria asi
<center>
   <form action='EnviarInfo.php' method="post">

    <div align="center">
                    <input align="center" name="EnviarInfo" class="btn btn-primary btn-block" type="submit" style="width: 50%"  value="Asignar">
            </div>
        </form>
    </center>

your modified php file

   <?php
//siempre pon tu conexion primero que todo para que tenga un uso mas global
$link = mysqli_connect("localhost","pcomp","KneTPuxJ77f4YLNX", "xxxx"); 

//aqui teneis que poner Enviarinfo dentro isset para saver si esta definida
 if (isset($_POST["EnviarInfo"])) 



    $causa_falla = $_POST['causa_falla'];
    $c1 = $_POST['c1'];
    $c2 = $_POST['c2'];
    $c3 = $_POST['c3'];
    $c4 = $_POST['c4'];
    $c5 = $_POST['c5'];
   $date = date('Y-m-d H:i:s');
   $obs = $_POST['obs'];
   $par = $_POST['par'];


  if ($_POST['estado'] == 'Rechazado'){
        $sql = "UPDATE avisos_auditados set estado='No es Falla' f_termino='".$date."' where id_aviso='".$id_p."'";



    if(mysqli_query($link, $sql)){

                echo "<script>alert('Cambios realizados, Asignar CFN')</script>"; 

            } else{

                echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
            }

              $yourURL="ver_aviso_auditado.php?id=$aux";
              //echo ("<script>location.href='$yourURL'</script>");
            echo"<META HTTP-EQUIV='Refresh' CONTENT='0;url=$yourURL'/>"; 



    }
    else if ($_POST['estado'] == 'Aprobado'){

        if ($c1 == "" && $c2 == "" && $c3 == "" && $c4 == "" && $c5 == "" ) {

            echo "<script>alert('Debe ingresar una cuenta como minimo ingresar una cuenta')</script>";

        }else {

            $contadorCuentas = 0;

            if ($c1 == "" ) {

                $contadorCuentas = $contadorCuentas + 0;
            }else{

                $contadorCuentas = $contadorCuentas + 1;

            }

            if ($c2 == "" ) {

                $contadorCuentas = $contadorCuentas + 0;
            }else{

                $contadorCuentas = $contadorCuentas + 1;

            }

            if ($c3 == "" ) {

                $contadorCuentas = $contadorCuentas + 0;
            }else{

                $contadorCuentas = $contadorCuentas + 1;

            }

            if ($c4 == "" ) {

                $contadorCuentas = $contadorCuentas + 0;
            }else{

                $contadorCuentas = $contadorCuentas + 1;

            }

            if ($c5 == "" ) {

                $contadorCuentas = $contadorCuentas + 0;
            }else{

                $contadorCuentas = $contadorCuentas + 1;

            }

            $sql = "UPDATE avisos_auditados set estado='Es Falla', f_termino='".$date."' where id_aviso='".$id_p."' ";

            $sql2 = "INSERT INTO avisos (tipo_defecto, direccion, agencia, central, tipo_cable, cable, armario, cuenta1, cuenta2, cuenta3,cuenta4,cuenta5, fecha_ingreso, fecha_revisar_aviso, fecha_respuesta_aviso) 
                     VALUES ('$tipo_defecto','$direccion', '$agencia', '$central', '$central','$tipo_cable','$cable','$armario',cuenta1='$c1', cuenta2='$c2',cuenta3='$c3',cuenta4='$c4',cuenta5='$c5','$date','$date','$date')";

            if(mysqli_query($link, $sql) and mysqli_query($link, $sql2)){

                echo "<script>alert('Cambios realizados, Asignar CFN')</script>"; 

            } else{

                echo "ERROR: Could not able to execute $sql:" . mysqli_error($link);
            }
            try {
                echo $_POST[EnviarInfo];
            } catch (Exception $e) {
                echo "exepcion campturada:".$e->intl_get_error_message();

            }

              $yourURL="revisar_aviso_falla.php?id=$aux";
              //echo ("<script>location.href='".$yourURL."'</script>");
            echo"<META HTTP-EQUIV='Refresh' CONTENT='0;url=$yourURL'/>"; 

            }

    }


}


?>

I hope you serve as an example greetings!

    
answered by 21.09.2018 в 20:49