First please use the [NOPARSE]
[/NOPARSE] tags when posting php code.
Second, in your form you have 2 fields named answer (hidden, and text).
Third, you are comparing the forms answer field to the newly created $calc value (as this will change every page load based on the random number generated on page load). Instead you probably want to compare the hidden field and the input field.
Fourth, your input are in two different forms. Therefore when submitted only the typed input will get sent, not the hidden field.
Fifth, your if statement is not using a comparison operator but instead an assignment operator. You need two equals signs (or 3 to compare type casting as well) for comparison as opposed to just one.
I'm not entirely sure what you are doing from your code/desc however, you should probably have the hidden field be the starting number, and do the math in your code on submit - this way the correct answer isn't view-able in the source. Give something like the following a shot:
<?php
if( !isset($_GET['answer']) ) {
$num = rand(29,99); // I prefer to have the lower end of the spectrum first
} else {
$num = $_GET['start'] > 14 ? $_GET['start'] - 7 : rand(29,99);
}
?>
<?php echo $num; ?> - 7 = ?<br/>
<form action="" method="GET">
<input type="text" name="answer" /><br />
<input type="hidden" name="start" value="<?php echo $num; ?>" />
<input type="submit" value="Submit" /><br />
</form>
<?php
if( isset($_GET['answer']) ) {
if( $_GET['answer'] == ($_GET['start']-7) ) {
echo 'Correct answer!';
} else {
echo 'Incorrect answer.';
}
}
?>
I know based on your description this is not exactly what you are after, but I hope it helps you get on the right track. HTH