<HTML>
<head><title></title>
<link rel="stylesheet" type="text/css" href="/css/scriptskewl.css">
</head>
<BODY>
<?
$q 
= array(2,0,1,2,2);
$q1_bad = array("is a container for integers only"
                
"name can start with a number"
                
"can contain words, sentences, integers");
$q2_bad = array("a container for strings"
                
"a mathematical approach to storing integers"
                
'$string[x]');
$q3_bad = array("CGI""HTML""PHP");
$q4_bad = array("HTML & CGI""PHP""HTML & PHP");
$q5_bad = array("sint""intrand""srand");

if (
$_POST['action'] == "true") { 
  
$right 0;
  print(
"Thank you for taking the PHP Quiz!");

    if (
$_POST['answer_1'] == $q[0]) { $right++; }
    if (
$_POST['answer_2'] == $q[1]) { $right++; }
    if (
$_POST['answer_3'] == $q[2]) { $right++; }
    if (
$_POST['answer_4'] == $q[3]) { $right++; }
    if (
$_POST['answer_5'] == $q[4]) { $right++; }

  
$percentage = ($right 5) * 100;
  print(
"<p>You scored <strong>$percentage %</strong> on the quiz!</BODY></HTML>");
  exit;
}
?>

<FORM METHOD="POST" ACTION="forms_quiz.php">
<input type="hidden" name="action" value="true">
Take the PHP Week 5 Quiz<p>
Question 1: A string is ... <br>

<? /* The long handed way
<input type="radio" value="0" name="answer_1"><? echo($q1_bad[0]); ?>
<input type="radio" value="1" name="answer_1"><? echo($q1_bad[1]); ?>
<input type="radio" value="2" name="answer_1"><? echo($q1_bad[2]); ?>
 */
?>

<? // The better way
for($i 0$i3$i++){
     print(
"<input type=\"radio\" value=\"$i\" name=\"answer_1\">$q1_bad[$i] 
     "
);
}
?>

<br>Question 2: An array is ...
<select name="answer_2">
<option selected value="0"><? echo($q2_bad[0]); ?></option>
<option value="1"><? echo($q2_bad[1]); ?></option>
<option value="2"><? echo($q2_bad[2]); ?></option>
</select>
<br>Question 3: Building a form primarily requires ...
<input type="radio" value="0" checked name="answer_3"><? echo($q3_bad[0]); ?>
<input type="radio" value="1" name="answer_3"><? echo($q3_bad[1]); ?>
<input type="radio" value="2" name="answer_3"><? echo($q3_bad[2]); ?>
<br>Question 4: This script is an example of ...
<select name="answer_4">
<option selected value="0"><? echo($q4_bad[0]); ?></option>
<option value="1"><? echo($q4_bad[1]); ?></option>
<option value="2"><? echo($q4_bad[2]); ?></option>
</select>
<br>Question 5: Before generating random numbers you use ...
<input type="radio" value="0" name="answer_5"><? echo($q5_bad[0]); ?>
<input type="radio" value="1" name="answer_5"><? echo($q5_bad[1]); ?>
<input type="radio" value="2" name="answer_5"><? echo($q5_bad[2]); ?>
<p><center><input type="submit" value="Submit"> <input type="reset" value="Reset"></center>

</FORM>

<pre>
</pre>
<br>
<iframe src='formsquizsource.php' width='850' height='300'></iframe>
<br>
<a href='../index.html'>BACK</a>

</BODY>
</HTML>