<?php
/**
 * controllers/compostTestSubmit.php
 *
 * POST handler for compost test entry.
 * NOTE: Compost form fields are pending migration — this is a stub.
 */

if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

require_once __DIR__ . '/../config/database.php';
require_once __DIR__ . '/../lib/auth.php';
require_once __DIR__ . '/../lib/csrf.php';

requireLogin();

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    header('Location: /dashboard/crop-analysis/compost-test-data/compost-test-data.php');
    exit;
}

if (!verifyCsrfToken($_POST['csrf_token'] ?? '')) {
    $_SESSION['flash_error'] = 'Invalid CSRF token. Please try again.';
    header('Location: /dashboard/crop-analysis/compost-test-data/compost-test-data.php');
    exit;
}

// Compost form fields not yet defined — redirect with info message
$_SESSION['flash_error'] = 'Compost test submission is pending full migration. Please contact your administrator.';
header('Location: /dashboard/crop-analysis/compost-test-data/compost-test-data.php');
exit;
