2
I have the following function within my class
public function update(){
try{
$stmt = $this->conn->prepare("UPDATE Tabela SET Dado1 = :Dado1, Dado2 = :Dado2, Dado3 = :Dado3 WHERE DadoId = :DadoId");
$stmt->bindParam(':Dado1', $Dado1, PDO::PARAM_STR);
$stmt->bindParam(':Dado2', $Dado2, PDO::PARAM_STR);
$stmt->bindParam(':Dado3', $Dado3, PDO::PARAM_STR);
$stmt->execute();
if ($stmt > 0)
{
header ( "location:retorno.php" );
}
return $stmt;
}catch (PDOStatement $excption){
header("Location: ./error.php?err=Unable to insert");
echo 'Erro: '.$exception->getMessage();
return null;
}
}
And usually I do a post method to send it:
$up = new Classe();
if($_SERVER['REQUEST_METHOD']=='POST'){
if(isset($_POST['btn-update']))
{
$stDado1= strip_tags($_POST['stn-Dado1']);
$stDado2 = strip_tags($_POST['stn-Dado2']);
$stDado3 = strip_tags($_POST['stn-Dado3']);
$sendInsert = $up->update($stDado1, $stDado2, $stDado3);
}
exit();
}
Only I got a problem, man Dado3 is a TAG <div>
, which receives a Text, I receive through Jquery a .html()
, because what was written in the database is an HTML code.
<form method="POST">
<div class="form-group">
<label>Dado 1</label>
<input class="form-control" name="dado1" type="text" >
</div>
<div class="form-group">
<label>Dado 2</label>
<input class="form-control" name="dado2" type="text">
</div>
<div class="form-group">
<label>Dado 3</label>
<hr>
<div name="dado3" contentEditable="false">
</div>
</div>
<hr>
<a class="btn btn-warning edit">Editar</a>
<a class="btn btn-warning cancel">Cancelar</a>
<button type="submit" name="btn-update" class="btn btn-danger ">Salvar</button>
</form>
Is there any way I can send this <div name="dado3" contentEditable="false"></div>
, to the bank via ajax or some other method?
Yes is possible, only form tags have attribute
name
, your div must have oneid
, take it with jquery and send it via ajax to php, you may need to handle it in html.– rray
@rray my problem is how to pass an object-oriented ajax, you have some good documentation about it, I’m looking pretty much at google, but it’s really not getting into my head that.
– Wagner Viana