This PHP example program demonstrates how to write and handle a self-processing get form.
<!DOCTYPE html>
<html>
<head>
<title>XoaX.net's PHP</title>
</head>
<body>
<?php
$dInches = NULL;
if (isset($_GET['sInches'])) {
$dInches = $_GET['sInches'];
}
// The initial request
if (!is_numeric($dInches)) {
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="GET">
Inches: <input type="text" name="sInches" /><br /><br />
<input type="submit" name"sConvert">
</form>
<?php
// The subsequent request
} else {
$dCentimeters = (2.54*$dInches);
printf("%g inches = %g centimeters", $dInches, $dCentimeters);
}
?>
</body>
</html>
© 20072025 XoaX.net LLC. All rights reserved.