prepare('DELETE FROM products WHERE id = ?'); $stmt->execute([$id]); // Check if any row was deleted if ($stmt->rowCount() > 0) { header('Location: products.php?status=deleted'); } else { header('Location: products.php?error=not_found'); } exit; } catch (PDOException $e) { // Handle DB error // error_log($e->getMessage()); header('Location: products.php?error=db'); exit; }