<?php
/*
   function: to multiply the two input numbers and display the result,
    with a form for data entry. Input values become the default form values.
    ( a 'sticky form')
 
   input:
      x, y : numbers
      calc : Calculate button pressed

   author:
      Chris Wallace
      9 Oct 2004

*/

// first compute the output, but only if data has been input
   
if(isset($calc)) { // $calc exists as a variable
      
$prod $x $y;
   }
   else { 
// set defaults
      
$x=0;$y=0;$prod=0;
   }
?>

<form method="get" action="<?php print $PHP_SELF?>">
x = <input type=text name="x" size="5" value="<?php print $x?>"/>
y=  <input type=text name="y" size="5" value="<?php  print $y?>"/>
x * y = <?php print $prod ?>
<br/><input type="submit" name="calc" value="Calculate"/>
</form>