1
So I have a modal that shows the data of the number that was searched, I want that when clicking the button edit of the modal release the inputs: work, rca and region to be able to write inside these inputs and also the button save to perform the update in the database, I already made the page that updates...
modal code:
<?php
include_once("../conn/conexao.php");//faz a conexao com o banco de dados
if(!empty($_POST['numerodigitado'])){
$numerodigitado = $_POST['numerodigitado'];
$result = "SELECT * FROM tb_numeros WHERE numero = '$numerodigitado' ";
$resultado = mysqli_query($conexao, $result);
$row = mysqli_fetch_assoc($resultado);
if($resultado -> num_rows > 0){
echo"
<div class='modal fade' id='squarespaceModa2' 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'>Close</span></button>
<div class='modal-body'>
<div class='form-group'>
<div class='col-xs-12'><center>
<label for='exampleInputPassword1'>Funcionário</label></center>
<input type='text' name='funcionario' class='form-control' id='exampleInputPassword1' value=".$row['funcionario']." style='text-align: center;' readonly='readonly' >
<br></div>
</div>
<div class='form-group'>
<div class='col-xs-3'><center>
<label for='exampleInputPassword1'>Número</label></center>
<input type='text' name='numero' class='form-control' id='exampleInputPassword1' value=".$row['numero']." style='text-align: center;' readonly='readonly' >
</div>
</div>
<div class='form-group'>
<div class='col-xs-2'><center>
<label for='exampleInputPassword1'>RCA</label></center>
<input type='text' name='rca' class='form-control' id='exampleInputPassword1' value=".$row['rca']." style='text-align: center;' readonly='readonly' >
</div>
</div>
<div class='form-group'>
<div class='col-xs-7'><center>
<label for='exampleInputPassword1'>Região</label></center>
<input type='text' name='regiao' class='form-control' id='exampleInputPassword1' value=".$row['regiao']." style='text-align: center;' readonly='readonly' >
<br></div>
</div>
<div class='form-group'>
<div class='col-xs-6'><center>
<label for='exampleInputPassword1'>Número Chip</label></center>
<input type='text' name='nchip' class='form-control' id='exampleInputPassword1' value=".$row['nchip']." style='text-align: center;' readonly='readonly' >
</div>
</div>
<div class='form-group'>
<div class='col-xs-6'><center>
<label for='exampleInputPassword1'>IMEI</label></center>
<input type='text' name='imei' class='form-control' id='exampleInputPassword1' value=".$row['imei']." style='text-align: center;' readonly='readonly' >
<br></div>
</div>
<div class='form-group'>
<div class='col-xs-12'><center>
<label for='exampleInputPassword1'>Cadastrado Por</label></center>
<input type='text' name='funcionario' class='form-control' id='exampleInputPassword1' value=".$row['usuario']." style='text-align: center;' readonly='readonly' >
<br></div>
</div>
<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-danger' role='button'>Editar</button>
</div>
<div class='btn-group' role='group'>
<input class='btn btn-success btn-hover-green' role='button' type='submit' value='Cadastrar' name='Salvar'>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){ $('#squarespaceModa2').modal(); });
</script>";
}
else {
echo "<script>
alert('Número não encontrado.');
window.location='index.php';
</script>";
}
}
?>
update.php page:
<?php
session_start();
include("../conn/conexao.php");
$numero = $_GET["numero"];
$funcionario= $_POST["funcionario"];
$rca= $_POST["rca"];
$regiao= $_POST["regiao"];
$nome=$_SESSION['nome'];
$up = mysqli_query($conexao, "UPDATE tb_numeros SET funcionario='$funcionario', rca=$rca, regiao='$regiao', usuario='$nome' WHERE numero = $numero ")or die (mysqli_error($conexao));
if($up):
echo "<script>
alert('Alterado com sucesso.');
window.location='index.php';
</script>";
else:
echo "<script>
alert('Ocorreu um erro ao atualizar, entre em contato com o administrador.');
window.location='index.php';
</script>";
endif;
?>
What is the problem?
– Rafael Augusto