stop1; echo "Sum Game"; error_reporting(E_ALL | E_NOTICE); /*error report*/ $one = rand(1,1000); /*generate random number for cauculation*/ $two = rand(1,1000); /*generate random number for cauculation*/ echo "

$one + $two=

"; /*show formula*/ echo << stop2; if(($_SERVER['REQUEST_METHOD'] !== 'POST') || @$_POST['input'] === ""){ /*check if the POST exist or the answer is NULL*/ GOTO end; /*if not, skip all the out put*/ } $ans = $_POST['num1']+$_POST['num2']; /*calculate the correct answer*/ if(!(is_numeric($_POST['num1'])&&is_numeric($_POST['num2'])&&is_numeric($_POST['input']))) {echo "wrong input: \"",htmlspecialchars($_POST['input'],ENT_QUOTES),"\""; die(); } result_output: if($ans==$_POST['input']){ echo "

You're right!

", $_POST['num1'], "+", $_POST['num2'], "=", $ans; }elseif ($ans!=$_POST['input']){ echo "

That's wrong :(


", $_POST['num1'], "+", $_POST['num2'], "=", $ans; echo "
Your input is", htmlspecialchars($_POST['input'],ENT_QUOTES), ", right answer is", $ans; echo "
", abs($_POST['input']-$ans), " difference from the correct answer"; } end: echo '

home page'; echo <<< stop1 stop1;