<html>
<head>
Einfacher PHP-Rechner
</head>
<body>
Bitte geben Sie zwei Zahlen ein:
<!-- <form action="form_rechner.php" method="GET"> -->
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="GET">
<table>
<tr>
<td>Erste Zahl: </td>
<td><input type="Text" name="zahl1"></td>
<td><input type="Submit" name="plus" value="Addieren"></td>
</tr>
<tr>
<td>Zweite Zahl: </td>
<td><input type="Text" name="zahl2"></td>
<td><input type="Submit" name="mal" value="Multiplizieren"></td>
</tr>
</table>
</form>
<?php
if ( isset($_GET["plus"]) && !empty($_GET["zahl1"]) && !empty($_GET["zahl2"]) )
{$ergebnis=$_GET["zahl1"]+$_GET["zahl2"];
echo "<br>".$_GET["zahl1"]." + ".$_GET["zahl2"]." = ".$ergebnis;
}
if (isset($_GET["mal"]) && !empty($_GET["zahl1"]) && !empty($_GET["zahl2"]))
{$ergebnis=$_GET["zahl1"]*$_GET["zahl2"];
echo "<br>".$_GET["zahl1"]." * ".$_GET["zahl2"]." = ".$ergebnis;
}
?>
</body>
</html>