Good afternoon, friends, I'm having a problem, I can not register all the users in the database, just register the last one, how can I solve this problem?
Index
<formmethod="post" action="salvar.php">
Name CPF Position - Function Email Kinship Actions
<select name="cargo">
<option value="gerente" name="gerente">Gerente</option>
<option value="Professor" name="Professor">Professor</option>
<option value="Programador" name="Programador">Programador</option>
</select>
</td>
<td><input type="text" name="email"></td>
To remove
Add Dependents
Register
save.php
$nome = $_POST['nome'];
$cpf = $_POST['cpf'];
$cargo = $_POST['cargo'];
$email = $_POST['email'];
$parentesco = $_POST['parentesco'];
// faz consulta no banco para inserir os dados do usuario
$sql = "insert into cad_dependentes (nome, cpf, cargo, email, parentesco) values ('$nome', '$cpf', '$cargo', '$email', '$parentesco')";
function.js
(function($) {
RemoveTableRow = function(handler) {
var tr = $(handler).closest('tr');
tr.fadeOut(400, function(){
tr.remove();
});
return false;
};
AddTableRow = function() {
var newRow = $("<tr>");
var cols = "";
cols += '<td><input type="text" name="nome"></td>';
cols += '<td><input type="text" name="cpf"></td>';
cols += '<td><select name="cargo">';
cols += '<option value="gerente" name="gerente">Gerente</option>';
cols += '<option value="Professor" name="Professor">Professor</option>';
cols += '<option value="Programador" name="Programador">Programador</option>';
cols += '</select></td>';
cols += '<td><input type="text" name="email"></td>';
cols += '<td><input type="text" name="parentesco"></td>';
cols += '<td class="actions">';
cols += '<button class="btn btn-large btn-danger" onclick="RemoveTableRow(this)" type="button">Remover</button>';
cols += '</td>';
newRow.append(cols);
$("#products-table").append(newRow);
return false;
};
})(jQuery);