scottlpool2003
Newbie
- May 6, 2009
- 14
- 7
Hey guys, I need to develop a website as part of my placement project for uni but I'm having a hard deal from the start.
I need to develop a website that includes some example questions where users enter the sum and see the answer. I've done this bit with no problem.
My problem is showing the sum and making the user answer the question and using an IF statement to calculate the answer and check it against what the user inputted. If they got it right I need to show "GOOD JOB" Else, "HARD LUCK"
It's driving me insane, I'd appreciate it greatly if someone can help me out!
I need to develop a website that includes some example questions where users enter the sum and see the answer. I've done this bit with no problem.
My problem is showing the sum and making the user answer the question and using an IF statement to calculate the answer and check it against what the user inputted. If they got it right I need to show "GOOD JOB" Else, "HARD LUCK"
It's driving me insane, I'd appreciate it greatly if someone can help me out!
PHP:
<?
if($_POST['Submit']!=''){
$variable_a = $_POST['variable_a'];
$variable_b = $_POST['variable_b'];
$result = $variable_a + $variable_b;
echo "<h1>$variable_a + $variable_b = $result</h1>";
if
$txtans = ($variable_a + $variable_b));
echo"great job!";
}
?>
<form name="calc" method="post">
<input name="variable_a" value="2" type="text" id="variable_a">
+
<input name="variable_b" value="1" type="text" id="variable_b">
<input name="txtans" type="text" id="variable_b">
<input type="submit" name="Submit" value="Calc">
</form>