1
On one page I have a material registration form, in another I have a table that shows all the materials registered with a button to change the information about a material and this button opens a third page with the same form of the first page only that already filled with the information just for you to change.
Only when I change the information and click to save, the saved script appears and it does not change the information.
This is my editing form:
<?php
require 'strcon.php';
$query = mysqli_query($strcon, "SELECT MATERIAL FROM materiais");
$material = filter_input(INPUT_POST, 'MATERIAL');
$quantidade = filter_input(INPUT_POST, 'QUANTIDADE');
$id = filter_input(INPUT_POST, 'ID');
?>
<!-- formulário -->
<form method="POST" action="update-est.php">
<div class="container">
<div class="row">
<div class="col-lg-8 col-md-10 mx-auto">
<div class="form-group">
<label for="MATERIAL">Material:</label>
<input type="text" class="form-control" id="MATERIAL" name="MATERIAL" value="<?php echo $material; ?>">
</div>
<div class="form-group">
<label for="QUANTIDADE">Quantidade:</label>
<input type="text" class="form-control" id="QUANTIDADE" name="QUANTIDADE" value="<?php echo $quantidade;?>">
</div>
<button type="submit" class="btn btn-primary btn-lg btn-block">Salvar</button>
</div>
</div>
</div>
</form>
<hr>
And this is my update:
<!--Update Estoque-->
<?php
$quantidade = filter_input(INPUT_POST, 'QUANTIDADE');
$id = filter_input(INPUT_POST, 'ID');
$strcon = mysqli_connect('localhost', 'root', '', 'sis_tam') or die('Erro ao conectar ao banco de dados');
$sql = "UPDATE `sis_tam`.`materiais` SET `QUANTIDADE` = '$quantidade' WHERE `materiais`.`ID` = '$id' ";
mysqli_query($strcon,$sql) or die("Erro ao tentar atualizar registro. " . mysqli_error($strcon));
mysqli_close($strcon);
echo '<script type="text/javascript">
alert("Salvo com Sucesso !");
window.history.go(-1);
</script>';
?>
Can anyone identify why this is happening?
Comments all "echo script" that and tries to print your $sql on screen and test it in hand.
– Diego Filipe Pedro Santos
string(84) "UPDATE
sis_tam
.materiais
SETQUANTIDADE
= '3' WHEREmateriais
.ID
= '' " `Looks like he’s not getting the ID– Mariana Bayonetta
tries to print this $id from above, if you don’t take a look at the previous page
– Diego Filipe Pedro Santos