I can not insert data into MYSQL if I use the action in HTML to go to page

0

The code I have is the following:

<form method="post" action="ingre_acta_exi.php">
  <table class="table bg-info" id="tabla">
    <tr class="fila-fija">
      <td><input type="number" name="IDE[]" id="IDE" value=""/></td>
      <td><input type="text" name="PLANILLA[]" id="PLANILLA" pattern="[0-9]{6}" value=""/></td>
      <td><input value="" type="text" name="N_PEDIDO[]" id="N_PEDIDO"/></td>
    </tr>
  </table>
  <div class="btn-der">
    <button id="adicional" name="adicional" type="button" class="btn btn-warning">Agregar</button>
    <input type="submit" name="insertar" id="insertar" value="Insertar" class="btn btn-info"/>
  </div>
</form>

PHP

<?php

if(isset($_POST['insertar']))
{
  $items2 = ($_POST['IDE']);
  $items3 = ($_POST['PLANILLA']);
  $items4 = ($_POST['N_PEDIDO']);

  while(true){

    //Recuperar los valores de los arreglos
    $item2 = current($items2);
    $item3 = current($items3);
    $item4 = current($items4);

    $valores ='('.$ide.',"'.$planilla.'","'.$n_pedido.'"),';

    $valoresQ = substr($valores, 0, -1);

    $sql = "INSERT INTO huawei_acta_entrega (IDE, PLANILLA, N_PEDIDO) 
    VALUES $valoresQ";

    $sqlRes = mysql_query($sql, $conexion) or mysql_error();

    $item2 = next($items2);
    $item3 = next($items3);
    $item4 = next($items4);

    if($item2 === false && $item3 === false && $item4 === false && $item5 === 
    false && $item6 === false && $item7 === false && $item8 === false && $item9 
    === false && $item10 === false && $item11 === false) break;
  }
}

?>
    
asked by Anderviver 14.09.2017 в 15:09
source

1 answer

1

At the end of the PHP insert code (after closing the while ) you could do a redirect using header , like this:

if(isset($_POST['insertar']))
{
  ...
  }// Llave que cierra el while
  header('Location: /pagina.php');
}
    
answered by 14.09.2017 / 23:34
source