<?php
session_start();
if($sonuc==""){
$sayi1 = rand(1,9);
$sayi2 = rand(1,9);
$cevap = $sayi1+$sayi2;
$_SESSION['cevap'] = $cevap;
echo $sayi1." + ".$sayi2." = ";
echo '<form method="POST">
<input type="text" name="sonuc">
<input type="submit" value="kontrol">
<form>';
}else{
$cevap = $_SESSION['cevap'];
$sonuc = $_POST['sonuc'];
if($cevap==$sonuc){
echo "dogru";
}else{
echo "yanlış";
}
}
?>