1
How to bring bank registration directly within a modal using PDO? Register using a modal I can, only I can not do the editing. In normal mode the records come good but when I click the EDIT button to bring the window with the records nothing happens!
Below follows the code.
HTML
<a href="modalLogin.php?update&id=<?php echo $rs->alun_id;?>" data-toggle="modal" data-target="#myModal" >Edite</a>
Javascript and PHP
if (isset($_POST['atualizar'])) {
$id = (INT) $_GET['id'];
$nome = $_POST['nome'];
$pgUpdate = 'UPDATE alunos SET alun_nome=:nome WHERE alun_id=:id';
$update = $db->prepare($pgUpdate);
$update->bindValue(':id', $id, PDO::PARAM_INT);
$update->bindValue(':nome', $nome, PDO::PARAM_STR);
$update->execute();
header("location: alunList.php");
}
//buscando dados preenchido para dentro do formulario
if (isset($_GET['update'])) {
$id = (int) $_GET['id'];
$pgSelect = 'SELECT * FROM alunos where alun_id = :id';
$select = $db->prepare($pgSelect);
$select->bindValue(':id', $id, PDO::PARAM_INT);
$select->execute();
$result = $select->fetch(PDO::FETCH_OBJ);
?>
<div class="container">
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header" style="padding:35px 50px;">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4><span class="glyphicon glyphicon-lock"></span> Login</h4>
</div>
<div class="modal-body" style="padding:40px 50px;">
<form role="form">
<div class="form-group">
<label for="nome"><span class="glyphicon glyphicon-user"></span> Username</label>
<input type="text" class="form-control" id="nome" name="nome" value="<?= $result->alun_nome; ?>">
</div>
<button type="submit" class="btn btn-success btn-block"><span class="glyphicon glyphicon-off"></span> Salvar</button>
</form>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-danger btn-default pull-left" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
<script>
$(document).ready(function () {
$("#myBtn").click(function () {
$("#myModal2").modal();
});
});
</script>
Look that question.
– KaduAmaral