0
I am working on a project with Bootstrap Modals. I have already done the modals to create content, delete, etc. But, I need to have one for editing... And I’m having a little trouble.
MODAL UPGRADE:
In this modal, the user will enter the carrier ID, and then the PHP below will search in SQL and bring other reallocated data (name, etc.). What I need, is that after the search with PHP, the user returns to the same page with a new modal that brings the data (example the name of the operator), which he can edit and finally run an update in SQL (changing the data).
<!-- Atualizar Operadora -->
<div class="modal fade" id="atualizarOperadora" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Fechar</span></button>
<h3 class="modal-title" id="lineModalLabel">Atualizar Operadora</h3>
</div>
<div class="modal-body">
<!-- content goes here -->
<form method="post" action="telaAtualizarConteudo.php">
<div class="form-group">
<label for="inputAtualizarOperadora">ID Operadora</label>
<input type="text" name="IDOperadora" class="form-control" id="inputAtualizarOperadora" placeholder="Insira o ID da Operadora">
</div>
<div class="modal-footer">
<div class="btn-group btn-group-justified" role="group" aria-label="group button">
<div class="btn-group" role="group">
<button type="button" class="btn btn-default" data-dismiss="modal" role="button">Fechar</button>
</div>
<div class="btn-group" role="group">
<button type="submit" name="atualizarOperadora" id="saveImage" class="btn btn-default btn-hover-green" data-action="save" role="button">Próximo</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
telaAtualizarConteudo.php
require_once("lib/conexao.php");
include('header.php');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['atualizarOperadora'])) {
$IDOperadora = (isset($_POST['IDOperadora'])) ? $_POST['IDOperadora'] : '';
$strSQL = "SELECT * FROM operadora WHERE operadoraID = ".$IDOperadora."";
$query = mysqli_query($con, $strSQL);
$result = mysqli_fetch_array($query);
The screen below does what I need, but on a separate page, not by modal, which ends up ruining the design I need.
echo '<div class="text-center logo"><img src="img/logo.png"></div>
<div class="container-fluid">
<div class="row">
<div class="col-lg-12 text-center">
<h1>Atualizar Operadora</h1>
<hr>
<form method="post" action="atualizarConteudo.php">
<div class="form-group">
<label for="inputAtualizarNomeOperadora">Operadora</label>
<input type="text" name="atualizarNomeOperadora" class="form-control" id="inputAtualizarNomeOperadora" value="'.$result["nome"].'">
<input type="hidden" name="IDOperadora" class="form-control" value="'.$IDOperadora.'">
</div>
<div class="btn-group" role="group">
<button type="submit" name="aceitaAtualizarOperadora" id="saveImage" class="btn btn-default btn-hover-green" data-action="save" role="button">Salvar</button>
</div>
</form>
</div>
</div>
<div class="row">
<div class="col-lg-12 text-center">
<a href="page.php?pagina=Dados" class="btn btn-default btn-xlarge btn-voltar" role="button"><i class="fa fa-undo"></i> Voltar</a>
</div>
</div>
</div>';
What you want to do is give a post in a form and continue with the same open after?? If yes this is not possible. for such you will need to implement this query with ajax. You know about?
– Emir Marques
Actually no.. But I managed in a way with GET, checking if it was set (isset) there opened another modal. It worked! = D thanks!
– Rodrigo BRF