Ok, this should be a simple assignment for my WebApps class which I just started this semester. I would really appreciate it if someone helped (a veteran would blaze through this in no time).
What the program is supposed to do is very simple:
-Generate two random variables between 0 and 12.
-Show the User a mathematical multiplication problem with the two variables, and ask them for the answer.
-if they get it right, tell them good job, if not, show them the correct answer.
-one php file
I have poured over and over my code, but I always get the "sorry, incorrect answer" page with NEW randomly generated numbers (different than the variable values than the previous page). I have tried hidden values in forms, but that didn't work. Here is the code please tell me where I went wrong:
<?
echo "<title>Multiplication Tutor by John Richter</title><h1><center>Multiplication
Tutor</center></h1>";
if ($ans=="")
{
$var1=rand(0,12);
$var2=rand(0,12);
echo "<font size=5><center>Let's see how good you are at multiplication. <br>
What's $var1 x $var2?<br>";
echo "<form action=\"$PHP_SELF\" method=post> <input type=text name=ans size=5>
<input type=submit value=\"--->\"></center></font>";
}
else
{
if ($ans==($var1*$var2))
{
echo "<center<h1>>GREAT!!!</h1>
<br><br><a href=\"http://electrontrap.com/assignment77.php\"><h2>Try Another
One!</h2></a></center>";
}
else
{
echo "<center><h1>Sorry. $var1 x $var2 = ",$var1*$var2;
echo "<br><br><a href=\"http://electrontrap.com/assignment77.php\"><h2>Try Another
One!</h2></a></center>";
}
}
?>