This PHP example program demonstrates how to write and handle a self-processing sticky get form.
<!DOCTYPE html>
<html>
<head>
<title>XoaX.net's PHP</title>
</head>
<body>
<?php
if (isset($_GET['sX'])) {
$dX = htmlspecialchars($_GET['sX']);
}
if (isset($_GET['sY'])) {
$dY = htmlspecialchars($_GET['sY']);
}
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="GET">
X = <input type="text" name="sX" value="<?php echo $dX ?>"/><br /><br />
Y = <input type="text" name="sY" value="<?php echo $dY ?>"/><br /><br />
<input type="submit" name"sMultiply">
</form>
<?php
// Only shown in the subsequent request
if (is_numeric($dX) && is_numeric($dY)) {
$dProduct = ($dX*$dY);
printf("%g * %g = %g", $dX, $dY, $dProduct);
}
?>
</body>
</html>
© 20072024 XoaX.net LLC. All rights reserved.