I have 4 fields and I want to save in a db, however when putting in foreach ($ _post ['name'] the $ name) ... I do not know how to add more ..
**DB**
id | vt | nome | qtn | id_cat
1 | 23 | qua..| 58 | 4
2 | 36 | não..| 57 | 2
register
<form action="php/cad.php" method="post">
<label>
<input type="button" class="btn btn-default" name="add" value="Add" />
</label>
<label>vt:</label>
<fieldset id="inputs_adicionais"></fieldset>
<input type="submit" value="Cadastrar" class="btn btn-default">
</form>
<script type="text/javascript">
$(document).ready(function(){
var input = '<label>Nome: <input type="text" name="vt[]" /> <input type="text" name="nome[]" placeholder="Nome"> <input type="text" name="qtn[]" placeholder="Qtn"> <input type="text" name="id_cat[]" placeholder="id cat"> <a href="#" class="remove">X</a></label>';
$("input[name='add']").click(function( e ){
$('#inputs_adicionais').append( input );
});
$('#inputs_adicionais').delegate('a','click',function( e ){
e.preventDefault();
$( this ).parent('label').remove();
});
});
</script>
register in db
<?php
include "conexao.php";
$vt = $_POST['vt'];
$nome = $_POST['nome'];
$qtn = $_POST['qtn'];
$id_cat = $_POST['id_cat'];
$sql = "INSERT INTO produto(vt, nome, qtn, id_cat) VALUES ('$vt', '$nome', '$qtn', '$id_cat')";
$query = $con->query($sql);
if($query!=null){
print "<script>window.location='../inicio.php';</script>";
}
?>