<?php
header('Content-Type: application/json');
// --- Include Database Connection ---
require_once 'db_connect.php';

// --- Database Connection ---
//$servername = "localhost";
//$username = "iktechnco_splashjet";
//$password = "iktechnco_splashjet";
//$dbname = "iktechnco_splashjet";

// Create connection
//$conn = new mysqli($servername, $username, $password, $dbname);

//// Check connection
//if ($conn->connect_error) {
//    die(json_encode(['status' => 'error', 'message' => 'Database connection failed.']));
//}





$imageUrl = isset($_POST['image_url']) ? $_POST['image_url'] : '';

if (!empty($imageUrl)) {
    $stmt = $conn->prepare("INSERT INTO popup_banners (image_url) VALUES (?)");
    $stmt->bind_param("s", $imageUrl);

    if ($stmt->execute()) {
        echo json_encode(['status' => 'success', 'message' => 'Popup banner added successfully.']);
    } else {
        echo json_encode(['status' => 'error', 'message' => 'Failed to add popup banner.']);
    }
    $stmt->close();
} else {
    echo json_encode(['status' => 'error', 'message' => 'Image URL is required.']);
}

$conn->close();
?>