<html>
<head>
<title>hitung</title>
</head>
<body>
<? if (!isset($hitung))
{?>
<form method="get" action="<? $PHP_SELF; ?>">
<input type="text" name="bilangan1" size="20">+
<input type="text" name="bilangan2" size="20">
<input type="submit" value="Hitung" name="hitung">
</form>
<?
}
else
{
$hasil=$bilangan1+$bilangan2;
echo "$bilangan1"."+"."$bilangan2";
echo "=".$hasil."<br>";
};
?>
</body>
</html>
<html>
<head>
<title>hitung</title>
</head>
<body>
<?php if (!isset($_GET['hitung']))
{?>
<form method="get" action="<?php $_SERVER['PHP_SELF']; ?>">
<input type="text" name="bilangan1" size="20">+
<input type="text" name="bilangan2" size="20">
<input type="submit" value="Hitung" name="hitung">
</form>
<?php
}
else
{
$hasil=$_GET['bilangan1']+$_GET['bilangan2'];
echo $_GET['bilangan1']."+".$_GET['bilangan2'];
echo "=".$hasil."<br>";
};
?>
</body>
</html>