<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><head>
<title>Saarland Beer Shop</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
</head>
<body>


<?php

// products 
$products[0]['name']="Grosswald Pilsener";
$products[0]['price']=1.56;
$products[1]['name']="Grosswald Export";
$products[1]['price']=1.34;
$products[2]['name']="Bruch Landbier";
$products[2]['price']=1.22;

// euro rate
$euro_rate=1.21;

// stuff we need in the form
$form_greet='<h1>Please place your order</h1>';
$form_top="<form action=\"$_SERVER[PHP_SELF]\" method=\"GET\"><table>";
$form_submit='</table><input type="submit" value="I order"/>';
$submit_check='<input type="hidden" name="submitted" value="1"/>';
$form_bottom='</form>';

// stuff we need it the order
$order_head="<h1>Results of your order</h1><div>\n";
$order_bottom="Thank you for your order. We will ship when we get your
check. Prosit!\n</div>";

if($_GET['submitted']) {
  // print the form
  // note that the form uses numbers as control
  // names 
  $total_euro=0;
  print $order_head;
  foreach($_GET as $number => $amount) {
    // find the product number for the handle      
    if($amount > 0 and $products[$number]) {
      $pay=$amount*$products[$number][price];
      print "$amount bottles of ";
      print $products[$number][name];
      print " is &euro;$pay<br/>";
      $total_euro+=$pay;
    }
  }
  $total_dollar=$total_euro*$euro_rate;
  $total_dollar=number_format($total_dollar,2);
  print "The euro rate is $euro_rate<br/>\n";
  print "Your bill is \$$total_dollar\n</div>";
}
else {
  print $form_greet;
  print $form_top;
  $product_count=0;
  foreach ($products as $prod) {
    print "\n<tr><td>";
    print $prod['name'];
    print "</td><td>";
    print "<input type=\"text\" name=\";
    print $product_count;
    print "\" maxlength=\"2\" size=\"2\"/>";
    print "</td><td>@&euro;";
    print $prod['price'];
    print "</td></tr>\n";
    $product_count++; // don't forget!
  }
  print $submit_check;
  print $form_submit;
  print $form_bottom;
}

?>


<p>
<a href="http://validator.w3.org/check?uri=referer"><img
    style="border: 0pt"
    src="/valid-xhtml10.png"
    alt="Valid XHTML 1.0!" height="31" width="88" /></a>
</p>
</body>
</html>



Valid XHTML 1.0!