<?

 $url 
"http://www.cs.indiana.edu/classes/a202-dger/fall2005/notes/flagquiz/images";
  
 
$names = array ("Australia""United States""Russia""Spain""Italy""South Africa""Brazil""China");

  if (
$message) {
    if (
$key) {
      if (
$answer == $key) {
        
$correct += 1;
        
$message "Very good."
      } else {
        
$message "No, that was not it."
      }
      
$total += 1;
      
$message .= " Score currently: $correct out of $total.";
    } else {
      
$message "Welcome to a new game, score currently: $correct out of $total.";  
    }
if (
$questions) {

    list(
$key$questions) = split(","$questions2);
    
$question "Whose country is this flag: <img src='$url/$key.png'> <input type=text name='answer'> <p>";
    } else {
      
$question "The game has ended, new game starting, are you ready? <p>";
      
$correct 0;
      
$total 0;
      
$questions join(","$names);
      
$key ""// there is no key in the beginning
    
}
    
  } else {
    
$message "Welcome to the game, are you ready?"
 
    
$correct 0
    
$total 0
    
$questions join(","$names);

    
$key ""// there is no key in the beginning
  

  
?>
 
  <form>
  <?=$message?> <p>
  <?=$question?>
  
  Press <input type="submit" value="Proceed"> to move on. 
  <input type="hidden" name="message" value="<?=$message?>">
 
  <input type="hidden" name="correct"   value="<?=$correct?>">
  <input type="hidden" name="total"     value="<?=$total?>">
  <input type="hidden" name="questions" value="<?=$questions?>">
  <input type="hidden" name="key"       value="<?=$key?>">

 </form>