Hi, I'm new to PHP and I'm trying to create a simple math game which utilizes an html form to pass on the user's answer to a php script that checks that answer. Here is what I have thus far:
game.php:
<!-DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-TRansitional.dTD">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PHP Practice</title>
</head>
<body>
<?php
function getRand(){
return rand(1,13);
}
$lhs=getRand();
$rhs=getRand();
?>
<form action="welcome.php?lhs=$lhs&rhs=$rhs" method="get">
<label value="<?php $lhs;?>" />
<label value="<?php $rhs;?>" />
<input type="text" name="answer" />
<input type="submit" value="Check Answer" />
</form>
</body>
</html>
check.php
<?php
$lhs = $_GET['lhs'];
$rhs = $_GET['rhs'];
$correct_answer = $lhs * $rhs;
if( $_GET['answer'] == $correct_answer )
echo "Correct!";
else
echo "Incorrect. " . $lhs . " X " . $rhs . " = " . $correct_answer;
?>
Of course it's not working. I know I'm probably way off and that the value="<?php ...
thing won't work like I'm used to in asp pages.
Your help/guidance is most apprectiated!
Thank You in advance