0
I find myself at:
- implement a form
- has several inputs with the same name
- I need to enter the data into the database
I intend at the moment:
- create a record for each user of the platform
the form has several fields linking to the various entries of the database
<div class="form nome_ch"> <label for="nome_ch">Nome</label> <input type="text" name="nome_ch[]" id="nome_ch"> </div> <div class="form cargo_ch"> <label for="cargo_ch">Cargo</label> <input type="text" name="cargo_ch[]" id="cargo_ch"> </div> <div class="form telefone_ch"> <label for="telefone_ch">Telefone</label> <input type="text" name="telefone_ch[]" id="telefone_ch"> </div> <div class="form email_ch"> <label for="email_ch">E-mail</label> <input type="text" name="email_ch[]" id="email_ch"> </div> <div class="form nascimento_ch"> <label for="nascimento_ch">Nascimento</label> <input type="text" name="nascimento_ch[]" id="nascimento_ch"> </div>
I don’t know how I do:
- enter in the database
There are several form parameters that connect the variables or parameters with identical names
In php you take the $_POST['name_ch'] data, it will be an array as sent in the html name="name_ch[]". It is OK to have several inputs with the same name if they have indicated as array in html by symbol [].
– fajuchem
yes, but my doubt is that there are 5 fields and not only 1
– Nicholas Ruschel Krüger
So that’s exactly it, if you send 2 inputs with name="name_ch[]", same names, you’ll get the 2 inputs in php by taking them for $_POST['name_ch'], and you’ll get an array with the 2 elements.
– fajuchem