1 2 |
$rawPostData = file_get_contents('php://input'); $jsonData = json_decode($rawPostData); |
Generate the Equation and Save the Result:
1 2 3 4 5 6 7 8 9 10 |
session_start(); $digit1 = mt_rand(1,20); $digit2 = mt_rand(1,20); if( mt_rand(0,1) === 1 ) { $math = "$digit1 + $digit2"; $_SESSION['answer'] = $digit1 + $digit2; } else { $math = "$digit1 - $digit2"; $_SESSION['answer'] = $digit1 - $digit2; } |
Display the Equation in your Form: