<?php
require 'db_config.php';

$title = $_POST['title'] ?? '';
$message = $_POST['message'] ?? '';

if (empty($title) || empty($message)) {
    die("Both title and message are required.");
}

$sql = "INSERT INTO notifications (title, message) VALUES (?, ?)";
$stmt = $conn->prepare($sql);

if (!$stmt) {
    die("Prepare failed: " . $conn->error);
}

$stmt->bind_param("ss", $title, $message);
$stmt->execute();

echo "Notification sent successfully.";
