0
I need to click a button, open a modal with a form for inserting data in mysql. I’m adapting a code I used earlier to display iframe, but when modal opens it shows the page inside the iframe with the php function. I need you to only open the form inside the modal to fill in. Follows:
Admin.php
<li> <a role="button" data-toggle="modal" href="#insere" class="fa fa-info-circle" style="font-size:18px"> Inserir</a></li>
<div class="modal fade" id="insere" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close blank" title="Fechar" data-dismiss="modal" aria-label="Fechar"><span aria-hidden="true">×</span></button>
<h2 class="modal-title text-center">Inserir</h2>
</div>
<div class="modal-body text-center">
<iframe width="100%" height="900px" frameborder="none"></iframe>
</div>
</div>
</div>
</div>
<script type="text/javascript">
//função JS
$('#insere').on('show.bs.modal', function () {
$('#insere iframe').attr('src','?insere');
});
$('#insere').on('hide.bs.modal', function () {
$('#insere iframe').removeAttr('src');
});
</script>
Commands.php
if (isset($_GET['insere'])) {
<form id="executainserir" method="post" enctype="multipart/form-data">
<strong>Inserir documentos no banco de dados:</strong>
<table width="1075" border="1">
<tbody>
<tr>
<td width="180" scope="col">Título:
<input name="titulo" type="text" autofocus required title="Título" size="30"></td>
<td width="498" scope="col">Descrição:
<input name="descricao" type="text" required title="Descrição" size="83"></td>
<td width="375" scope="col">Link:
<input name="link" type="url" value="http://" size="62"></td>
</tr>
</tbody>
</table>
<input name="arquivo" type="file" accept=".pdf" required title="Arquivo com extensão *.pdf" id="arquivo"><br>
<input type="submit" name="executainserir" value="Gravar">
</form>