I am developing a small application that will serve to update my knowledge, but in the development of the same I came across some inconsistent situations. I would like my "CRUD" to return a "div" that will display a css "alert" when executed by the browser, but when I run, only the alert is displayed and the rest of the form disappears (running on the same page).
database.class.php (initial project, only returns error)
// Delete
public function deleteDB($sql,$params=null){
$query=$this->connect()->prepare($sql);
$query->execute($params);
$rs = $query->rowCount() or die(print_r($query->errorInfo(),true));
self::__destruct();
return $rs;
}
Short HTML (example):
<?php
include './inc/database.class.php';
?>
<html>
<body>
<?php
$PDO = new database();
$resultado = $PDO->deleteDB("delete from usuario where login = :login and password = :password",array(':login' => "teste",':password' => "1234"));
?>
<div class="form">
<!-- inputs -->
<!-- buttons -->
</div>
</body>
</html>
database.class.php (change)
public function deleteDB($sql,$params=null){
$query=$this->connect()->prepare($sql);
$query->execute($params);
$rs = $query->rowCount() or die(print_r("<div class='alert' ... etc>",true));
self::__destruct();
return $rs;
}
Finally, I thought of other ways, even in a new class to handle the bugs, but I would like something simple like the example shown above. If anyone can help me thank you;)