<?php
// public/delete_book.php
session_start();
require '../src/db.php';

if (!empty($_GET['id'])) {
  $id = intval($_GET['id']);
  $stmt = $pdo->prepare("DELETE FROM libros WHERE id = ?");
  $stmt->execute([$id]);
  $_SESSION['flash'] = "Libro eliminado correctamente.";
}

$tab = $_GET['tab'] ?? 'books';
header("Location: index.php?tab={$tab}");
exit;