Hab eigentlich alles einbauen können außer das mit der Ausgabe in dem Textfeld.
<html>
<head>
</head>
<body>
<form name="Addition" action="<?php print $_SERVER["PHP_SELF"]; ?>" method="post">
<input type="text" name="zahl1" value="" length="10"><br>
<input type="text" name="zahl2" value="" length="10"><br>
<input type="submit" name="addition" value="berechne"><br>
<input type="radio" name="auswahl" value="1">+
<input type="radio" name="auswahl" value="2">-
<input type="radio" name="auswahl" value="3">*
<input type="radio" name="auswahl" value="4">/
<p>
<input type="text" name="ergebnis" value="<?php if (!empty($ergebnis)) {echo htmlspecialchars($ergebnis);} ?>">
</form>
<?php
if(isset($_POST["addition"])){
$wahl=$_POST["auswahl"];
$zahl1=$_POST["zahl1"];
$zahl2=$_POST["zahl2"];
if($wahl==1){
$ergebnis=$zahl1+$zahl2;
echo "<br>",$zahl1," + ",$zahl2," = ",$ergebnis," \n";
}
if($wahl==2){
$ergebnis=$zahl1-$zahl2;
echo "<br>",$zahl1," - ",$zahl2," = ",$ergebnis," \n";
}
if($wahl==3){
$ergebnis=$zahl1*$zahl2;
echo "<br>",$zahl1," * ",$zahl2," = ",$ergebnis," \n";
}
if($wahl==4){
if($zahl2==0){
echo $zahl1,"/ ", $zahl2, " ist nicht möglich";
}
else{
$ergebnis=$zahl1/$zahl2;
echo "<br>",$zahl1," / ",$zahl2," = ",$ergebnis," \n";
}
}
}
?>
</body>
</html>