Esempio n. 1
0
/*
* ----------------------------------------------------------------------
* AJAX: REMOVE SALE
* ----------------------------------------------------------------------
*/
if ($_POST) {
    require_once "../../../../static/_header.php";
    class AJAX
    {
        private $conn;
        function __construct()
        {
            $this->conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
        }
        function remove_promo($promo_item_id)
        {
            $sql = "DELETE FROM tbl_promo_item WHERE `promo_item_id` = ?";
            $stmt = $this->conn->prepare($sql);
            if ($stmt === false) {
                trigger_error('Database error: ' . $sql . ' Error: ' . $this->conn->errno . ' ' . $this->conn->error, E_USER_ERROR);
            } else {
                $stmt->bind_param("s", $promo_item_id);
                $stmt->execute();
            }
            $stmt->close();
        }
    }
    $_ajax = new AJAX();
    $promo_item_id = filter_var($_POST['item_id'], FILTER_SANITIZE_NUMBER_INT);
    $_ajax->remove_promo($promo_item_id);
}