<?php
include 'conex.php';
header('Content-Type: application/json');

$id = intval($_POST['id'] ?? 0);
$activo = intval($_POST['activo'] ?? 0);

if ($id <= 0) {
  echo json_encode(['success' => false, 'message' => 'ID inválido']);
  exit;
}

$stmt = $conex->prepare("UPDATE tb_publicidad SET activo = ? WHERE id = ?");
if ($stmt->execute([$activo, $id])) {
  echo json_encode(['success' => true]);
} else {
  echo json_encode(['success' => false, 'message' => 'Error al actualizar']);
}
