<?php
require __DIR__ . '/config.php';
$pdo = get_pdo();

$campaigns = $pdo->query("SELECT * FROM campaigns WHERE status='sending'")->fetchAll();

foreach ($campaigns as $c) {
    // your existing email send logic
    // Example: sendMailToList($c['list_id'], $c['template_id'], $c['subject']);
}


    $campaign_id = $_GET['cid'] ?? null;
    if (!$campaign_id) {
        die("Missing campaign ID");
    }

header("Location: send_worker.php?cid={$campaign_id}");

?>
