When i try to modify the values on the database with the form on the page, it simply gives me the successful message but it doesnt do anything.
<?php
include "header.php";
include "conexao.php";
echo "<h1>Pagina para alterar familia</h1><hr>";
$referencia=$_GET['id'];
$sql = "SELECT * ";
$sql = $sql . " FROM tb_familia ";
$sql = $sql . " WHERE fa_codigo='".$referencia."'";
$produtos = $db->query($sql);
foreach ($produtos as $produto) {
$referencia = $produto["fa_codigo"];
$nome = $produto["fa_descricao"];
//$preco = $produto["pr_preco"];
$disponivel = $produto["fa_disponivel"];
}
echo "<h2>Referencia: ".$referencia."</h2>";
echo "<h2>Nome: ".$nome."</h2><hr>";
?>
<form action="confirmaAlterarfamilia.php">
Referencia: <input type="text" name="referencia" value="<?php echo $referencia?>">
Nome: <input type="text" name="nome" value="<?php echo $nome?>">
<button>Alterar</button>
</form>
<p><p>
This is the other part of the code where it actually tries to modify things.
<?php
include "conexao.php";
$nome=$_GET['nome'];
$referencia=$_GET['referencia'];
$sql="UPDATE tb_familia SET fa_descricao='".$nome;
$sql.= " WHERE fa_codigo='".$referencia."'";
try{
$comando=$db->prepare($sql);
$comando->execute();
echo "<h1>Alterado com sucesso</h1>";
}
catch (PDOException $e){
echo "A";
}