1
Guys, currently I send one form
with several POST
, I receive them all and add them in the BD. However I am seeing a method using the var_dump
, but I don’t know how to implant it into my code.
An example of how I do today:
<?php
if ((!empty($action)) and ( $action == "envia")) {
// Recebe dados
$nome1 = filter_input(INPUT_POST, 'nome1', FILTER_DEFAULT);
$nome2 = filter_input(INPUT_POST, 'nome2', FILTER_DEFAULT);
// Adino no BD mysql
$mysqli->query("INSERT INTO nomes VALUES ('0', '$nome1')");
$mysqli->query("INSERT INTO nomes VALUES ('0', '$nome2')");
}
?>
<form name="form" method="post" action="index.php?action=envia">
<input type='text' name='nome1'>
<input type='text' name='nome2'>
<button type='submit'>Enviar</button>
</form>
Is there any way I can simplify this with var_dump
. This is a simple example, because I have a form with about 30 POST
.
the
var_dump()
doesn’t seem to solve your problem, it’s more like a array!– rray
You use an Insert in the same table for each element of your form?
– Fleuquer Lima
@Fleuquerlima this is an example, I actually have one
form
where I can register up to 10 user at once, so wanted to change the method I do understood.– Hugo Borges
var_dump() was not meant to receive or send anything, but rather to print an array / object on the screen.
– William Aparecido Brandino
@rray as would this method with array?
– Hugo Borges
Can do thus. Your form field should send an array, so just add brackets in the
name
make a check, after make a foreach with the Insert or mount the string of the Insert and send at once to the bank.– rray
@rray can answer the question with an example? so I can accept and finish the question.
– Hugo Borges
But he already put an example in the post that gave you the link, a look there
– Fleuquer Lima
Okay, I hadn’t seen hahahha
– Hugo Borges