PHP classes that returns "Alerts" css

Asked

Viewed 50 times

1

I am developing a small application that will serve to update my knowledge, however, in the development of it I came across some inconsistent situations. I would like my "CRUD" to return a "div" that will display an "Alert" css when run by the browser, but when run, only Alert is displayed and all the rest of the form disappears (running on the same page).

database.class.php (initial project, only returns the 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 a new class to deal with errors, but I would like something simple like the example shown above. If anyone can help me, I’d appreciate it ;)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.