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 "