Two submit to Edit and Insert in the same Form

1

This is my form:

<form name='form_update' method='post' id="registerUser" action='update.php'>

<input type='text' class='form-control' name='nombre' value=<?=$nombre; ?> />
<input type='text' class='form-control' name='ne' value=<?=$ne; ?> />

<input type='submit' value='Guardar Edición' class='btn btn-info' data-toggle='confirmation' data-title='Proceeder con esta Acción?' />

</form>

How can I add a second submit that sent me to a second address something like action='insert.php'

The intention is that when you finish editing some data as they appear in a form and you are satisfied with those changes you can have a button next to the update to save the information in a second table.

    
asked by claus 13.07.2018 в 20:35
source

1 answer

0

You can unify your code into a single file and have two buttons submit . The HTML would look like this:

<form name='form_update' method='post' id="registerUser" action='update.php'>

<input type='text' class='form-control' name='nombre' value=<?=$nombre; ?> />
<input type='text' class='form-control' name='ne' value=<?=$ne; ?> />

<input type='submit' name="guardar" value='Guardar Edición' class='btn btn-info' data-toggle='confirmation' data-title='Proceeder con esta Acción?' />
<input type='submit' name="insertar" value='Insertar Edición' class='btn btn-info' data-toggle='confirmation' data-title='Proceeder con esta Acción?' />

</form>

And then in your PHP file:

if (isset($_POST['guardar']) {
    /* Aqui harias el update */
}
if (isset($_POST['insertar']) {
    /* Aqui harias el insert */
}
    
answered by 13.07.2018 / 21:28
source