0
I have 2 files, the 1° is the form q will carry out the sending of the data and the 2° will process the data and update in the database, but the problem is q this is not happening, follow the code below... Note: Browser shows no error.
Form
<div id="<?php echo $mostra_produto['id_ovo'];?>editar" class="modal">
<div class="modal-content">
<h4 class="center blue-text">
Editar Produto
<p class="black-text smfont"><?php echo $mostra_produto['nome_ovo']; ?><br><span class="black-text smfont"><?php echo $mostra_produto['codigo_ovo']; ?></span></p>
</h4>
<form class="col s12 m12 l12 xl12" method="POST" action="processadores/processa_editar_ovo.php" enctype="multipart/form-data" autocomplete="off">
<div class="row">
<div class="input-field col s12 m12 l12 xl12">
<input name="titulo" type="text" id="titulo" autofocus />
<label for="titulo">Nome Do Ovo de Páscoa</label>
</div>
<div class="input-field col s12 m12 l12 xl12">
<textarea name="descricao" id="descricao" class="materialize-textarea" ></textarea>
<label for="descricao">Descrição</label>
</div>
<div class="input-field col s12 m12 l12 xl12">
<input name="preco" type="text" id="preco">
<label for="preco">Preço</label>
</div>
<div class="input-field col s12 m12 l12 xl12">
<input name="codigo" type="text" id="codigo" />
<label for="codigo">Codigo do Produto</label>
</div>
<div class="input-field col s12 m12 l12 xl12">
<p>
<label>
<input required="required" id="aceita" type="checkbox">
<span class="bold red-text">Confirmo que todas as informações foram preenchidas corretamente.</span>
</label>
</p>
</div>
<input class="btn-small green left" type="submit" name="editar" value="editar" />
<input class="modal-close btn-small red right" type="reset" name="cancelar" value="Cancelar" />
</div>
</form>
</div>
</div>
PDO
<?php
include_once("../classes/conexao.class.php");
Class Editar extends Conexao{
private $pdo;
private $id;
private $query;
public function __construct(){
$this -> id = $_GET['id_ovo'];
$this -> ExecutaUpdate($this->id);
}
private function MinhaConexao(){
$this->pdo = parent::getConecta();
}
private function ExecutaUpdate($id){
$this->MinhaConexao();
if(isset($_POST['editar'])){
$this->query = $this->pdo->prepare("UPDATE ovos SET nome_ovo = :titulo, descricao_ovo= :descricao, codigo_ovo = :codigo, preco_ovo = :preco WHERE id_ovo = :id_ovo");
$this->query->execute();
}
}
}
?>
Will this work ? if(isset($_POST['edit'])){ $this->query = $this->Pdo->prepare("UPDATE eggs SET name_ovo = '".$_POST['title']."', descricao_ovo = '".$_POST['Description']."', codigo_ovo = '".$_POST['codigo']."', preco_ovo = '".$_POST['preco']."' where '".$_POST['id_ovo']."' = '".$id."'"'); this$-->query->execute(); }
– Lukas Trindade
Well, I’ve never used it this way, but try, but I advise dealing with bindValue or bindParam
– Banks