<?php
session_start();

function generateMathProblem() {
    $num1 = rand(1, 20);
    $num2 = rand(1, 20);
    $operators = ['+', '-', '*'];
    $operator = $operators[array_rand($operators)];
    
    switch($operator) {
        case '+':
            $answer = $num1 + $num2;
            break;
        case '-':
            $answer = $num1 - $num2;
            break;
        case '*':
            $answer = $num1 * $num2;
            break;
    }
    
    $_SESSION['captcha_answer'] = $answer;
    $_SESSION['captcha_time'] = time();
    
    return "$num1 $operator $num2";
}

// Générer et stocker le problème mathématique
$mathProblem = generateMathProblem();
?>