38428-vm/api/log_announcement.php
2026-02-18 23:08:21 +00:00

21 lines
589 B
PHP

<?php
header('Content-Type: application/json');
require_once __DIR__ . '/../db/config.php';
$data = json_decode(file_get_contents('php://input'), true);
if (!$data || !isset($data['song_name'])) {
echo json_encode(['success' => false, 'error' => 'Datos incompletos']);
exit;
}
try {
$db = db();
$stmt = $db->prepare("INSERT INTO announcements_history (song_name) VALUES (?)");
$stmt->execute([$data['song_name']]);
echo json_encode(['success' => true]);
} catch (PDOException $e) {
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}