/home/wpollock1/public_html/PHP/comboform.php
<html><head><title>PHP Sample Combo Form</title></head>
<body>
<?php
session_start();
if ( array_key_exists('test_taken', $_REQUEST) )
process_form();
else
generate_form();
function generate_form () {
echo <<<EOF
<h1> Take a test </h1>
<form action="comboform.php" method="post">
<input type="hidden"name="test_taken" value="true">
</input>
<p> 1. what is the sum of 2 + 2? </p>
<input type="radio" name="q1" value="2">2</input><br>
<input type="radio" name="q1" value="3">3</input><br>
<input type="radio" name="q1" value="4">4</input><br>
<input type="radio" name="q1" value="5">5</input><br>
<input type="submit" name="submit" value="Grade the test now"></input>
</form>
EOF;
}
function process_form() {
echo '<p>';
$q1 = $_REQUEST['q1'];
$_SESSION['q1'] = $q1;
if ( $q1 == 4 )
echo 'Congatulations! <a href="comboform_results.php">click here</a> to print a certificate';
else
echo 'Sorry, try again!';
echo '</p>';
}
?>
</body></html>