My situation,
A POST form with a text input and two input radios.
Inputs are named respectively nome[0]
and tipo[0]
.
When someone adds more fields to the form, I put .attr to get nome[1]
and tipo[1]
and successively as it adds more inputs.
-
I did this to have how to transfer and prepare their information via POST in my php upload file.
-
It also helped me to keep radio buttons in the same group on different lines.
In the end, I would like these records in the MySql table in a table, in the name and type spaces.
So PHP
<?php
include 'conexao.php';
$nome = $_POST['nome']; // Aqui pega input text, o valor do name="nome[0]".
$tipo = $_POST['tipo']; // Aqui pega do input radio, o valor do name="tipo[0]".
if (is_array($nome)){
if (is_array($tipo)){
foreach($nome as $valornome) {
foreach($tipo as $valortipo) {
$carimbo = $con->prepare("INSERT INTO ingressos (nome,tipo) VALUES (?,?)");
$carimbo->bindValue(1,$valornome,PDO::PARAM_STR);
$carimbo->bindValue(2,$valortipo,PDO::PARAM_STR);
$carimbo->execute();
}}}}
It went wrong, but ...!
I can store only the correct radios, the name is cloned by the number of inputs generated :(
Form
HereMySql
I've been seeing some in materials before sending the data to have to organize the information I get from the vectors and then send, but I do not quite understand the texts I had access to ...
In short, what is the way to situations like this? Imagining, for example, a third input option ... I would love to get input on topics and readings.
My knowledge is very artificial, I understand a little of what is happening but not the depth of the logic of the codes.
Thank you in advance!