<html>
<title>PHP introduction - multiply script</title>
</head>
<body>
<img src="cems-banner.gif">
<h1>PHP introduction</h1>
<table><tr><td><img src="multiply.jpg"></td><td width="5%"</td><td><font color="red" size="+4">
<?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 204
*/
// first compute the output, but only if data has been input
if( isset($calc)) { // data was submitted
$prod = $x * $y;
}
else { // set defaults
$x=0;$y=0;$prod=0;
}
?>
<form method="get" action="<?php print $PHP_SELF; ?>">
<input type=text name="x" size="5" value="<?php print $x; ?>"/>
* <input type=text name="y" size="5" value="<?php print $y; ?>"/>
<input type="submit" name="calc" value="="/>
= <?php print $prod ?>
</form>
</font></td><tr></table>
</body>
</html>