fork download
  1. <?php
  2. require('conexao.php');
  3.  
  4. $nome = $_POST['nome'];
  5. $cpf = $_POST['cpf'];
  6. $cargo = $_POST['cargo'];
  7. $email = $_POST['email'];
  8. $parentesco = $_POST['parentesco'];
  9.  
  10. $pdo = Database::conexao();
  11.  
  12. $stmt = $pdo->prepare('INSERT INTO cad_dependentes (nome, cpf, cargo, email, parentesco) VALUES (:nome, :cpf, :cargo, :email, :parentesco)');
  13.  
  14. foreach ($_POST['usuarios'] as $usuario) {
  15.  
  16. $stmt->bindParam(':nome', $usuario['nome'], PDO::PARAM_STR);
  17. $stmt->bindParam(':cpf', $usuario['cpf'], PDO::PARAM_STR);
  18. $stmt->bindParam(':cargo', $usuario['cargo'], PDO::PARAM_STR);
  19. $stmt->bindParam(':email', $usuario['email'], PDO::PARAM_STR);
  20. $stmt->bindParam(':parentesco', $usuario['parentesco'], PDO::PARAM_STR);
  21.  
  22. $stmt->execute();
  23.  
  24. }
  25.  
  26. print_r($_POST);
  27. //echo var_dump($_POST['usuarios']);
  28. //header('refresh:10;index.php');
  29.  
  30.  
  31.  
  32. ?>
Runtime error #stdin #stdout #stderr 0.01s 52488KB
stdin
<form method="post" action="salvar.php">
  
 <table id="products-table" class="table table-hover table-bordered">
  <tbody>
  <tr>
      <th>Nome</th>
      <th>CPF</th>
      <th>Cargo - Função</th>
      <th>E-mail</th>
      <th>Parentesco</th>
     <th class="actions">Ações</th>
   </tr>
   <tr>
      <td><input type="text" name="nome[]"></td>
      <td><input type="text" name="cpf[]"></td>
      <td>

      <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>
   <td><input type="text" name="parentesco[]"></td>  
   <td class="actions">
      <button class="btn btn-large btn-danger" onclick="RemoveTableRow(this)" type="button">Remover</button>
   </td>
  </tr>
  </tbody>
                <tfoot>
  <tr>
      <td colspan="6" style="text-align: left;">
          <button class="btn btn-large btn-success" onclick="AddTableRow(this)" type="button">Adicionar Dependentes</button>
      </td>
  </tr>
               </tfoot>
 </table>
 <button type="submit" class="btn btn-info pull-right">Cadastrar</button>
</div>
</div>

</form>
stdout
Standard output is empty
stderr
PHP Warning:  require(conexao.php): failed to open stream: No such file or directory in /home/6uKI4H/prog.php on line 2
PHP Fatal error:  require(): Failed opening required 'conexao.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/6uKI4H/prog.php on line 2