This repository has been archived on 2026-06-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
sgd/ysqld/ysql04d/test2.php
T

85 lines
3.1 KiB
PHP

<!DOCTYPE html>
<html lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>TestFormular</title>
<?php
require("meinefunktionen.inc.php");
?>
</head>
<body>
<center>
<h1> Rechenmaschiene</h1>
<?php
if(is_numeric($_POST["zahl1"]) && is_numeric($_POST["zahl2"])) {
if(isset($_POST["zahl1"])){
switch($_POST["faktor"]){
case "+":
$ergebnis = addiere($_POST["zahl1"], $_POST["zahl2"]);
break;
case "-":
$ergebnis = subtrahiere($_POST["zahl1"], $_POST["zahl2"]);
break;
case "*":
$ergebnis = multipliziere($_POST["zahl1"], $_POST["zahl2"]);
break;
case "/":
$ergebnis = dividiere($_POST["zahl1"], $_POST["zahl2"]);
break;
default:
echo "<p><b>Bitte eine richtige Rechenoperation angeben!</b></p>\n";
break;
}
///echo "<p>Das Ergebnis von $zahl1 $faktor $zahl2 ist $ergebnis</p>\n";
}
}
else {
if(isset($_POST["zahl1"])){
echo "Bitte Nummern eingeben";
}
}
?>
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
<p>
Bitte geben Sie in den Feldern die Daten ein:
</p>
<p>
<label for="zahl1">Zahl 1</label>
<input type="text" name="zahl1" id="zahl1" placeholder="Zahl 1" required autofocus>
</p>
<p>
<label for="zahl2">Zahl 2</label>
<input type="text" name="zahl2" id="zahl2" placeholder="Zahl 2" required>
</p>
<p>
<li><input type="radio" name="faktor" id="addieren" value="+" constant>
<label for="addieren">+</label></li>
<li><input type="radio" name="faktor" id="subtrahieren" value="-">
<label for="subtrahieren">-</label></li>
<li><input type="radio" name="faktor" id="multiplikation" value="*">
<label for="multiplikation">*</label></li>
<li><input type="radio" name="faktor" id="division" value="/">
<label for="division">/</label></li>
</p>
<!--<p>
<label for="faktor">Faktor</label>
<input type="text" name="faktor" id="faktor" placeholder="+ - * /" required>
</p> -->
<p>
<input type="submit" value="Berechnen">
<input type="reset" value="Zurücksetzen">
</p>
</form>
<?php
if(isset($ergebnis/*$_POST["zahl1"]*/)){
echo "<p>Das Ergebnis von {$_POST["zahl1"]} {$_POST["faktor"]} {$_POST["zahl2"]} ist $ergebnis.</p>\n";
}
//echo "<p> " .$_SERVER["SERVER_ADMIN"] ."</p>\n";
?>
</center>
</body>
</html>