PHP Snippet 1:
<form>
<?php echo $questionID; ?>
<input type="text" name="answer" />
<input type="hidden" name="question" value="<?php echo $questionID; ?>" />
</form>
PHP Snippet 2:
$questions = array('dog legs','car legs','the best country in the world');
$answers = array(4,4,'USA');
$questionID = rand(0, (count($questions)-1));
if (isset($_POST['answer'])) {
$answer = $_POST['answer'];
$question = $_POST['question'];
if ( $questions[ $question ] == $answer ) // you're golden
}
PHP Snippet 3:
<input type="hidden" name="questionId" value="<?php echo $questionId; ?>"></input>
PHP Snippet 4:
<?php
if ($_POST['questionID'])
$questionID = $_POST['questionID'];
else
$questionID = rand(0, (count($questions)-1));