josephus
29.07.2011, 19:47:28
Hallo,
ich habe ein Übungsprogramm aus einem PHP-Einführungsbuch (Thomas Theis) übernommen. Es funktioniert leider teilweise nicht.
Programm Eingabeformular ub11
<html>
<body>
Bitte tragen Sie zwei Zahlen ein und senden Sie das
Formular ab.<p>
<form action = "ub11a.php" method = "post"> // oder "ub11b.php"
Wert 1: <input name = "w1"><p>
Wert 2: <input name = "w2"><p>
<input type = "submit">
<input type = "reset">
</form>
</body>
</html>
Programm Ausgabeformular ub11a
<html>
<body>
<?php
$erg = $w1 + $w2;
echo "Die Summe von $w1 und $w2 ist $erg";
?>
</body>
</html>
Programm Ausgabeformular ub11b
<html>
<body>
<?php
$erg = $_POST["w1"] + $_POST["w2"];
echo "Die Summe von " . $_POST["w1"] . " und " .
$_POST["w2"] . " ist $erg";
?>
</body>
</html>
ub11b funktioniert. ub11a liefert folgende Fehlermeldung:
Notice: Undefined variable: w2 in C:\xampp\htdocs\ub11a.php on line 4
Notice: Undefined variable: w1 in C:\xampp\htdocs\ub11a.php on line 4
Notice: Undefined variable: w1 in C:\xampp\htdocs\ub11a.php on line 5
Notice: Undefined variable: w2 in C:\xampp\htdocs\ub11a.php on line 5
Die Summe von und ist 0
Warum??
ich habe ein Übungsprogramm aus einem PHP-Einführungsbuch (Thomas Theis) übernommen. Es funktioniert leider teilweise nicht.
Programm Eingabeformular ub11
<html>
<body>
Bitte tragen Sie zwei Zahlen ein und senden Sie das
Formular ab.<p>
<form action = "ub11a.php" method = "post"> // oder "ub11b.php"
Wert 1: <input name = "w1"><p>
Wert 2: <input name = "w2"><p>
<input type = "submit">
<input type = "reset">
</form>
</body>
</html>
Programm Ausgabeformular ub11a
<html>
<body>
<?php
$erg = $w1 + $w2;
echo "Die Summe von $w1 und $w2 ist $erg";
?>
</body>
</html>
Programm Ausgabeformular ub11b
<html>
<body>
<?php
$erg = $_POST["w1"] + $_POST["w2"];
echo "Die Summe von " . $_POST["w1"] . " und " .
$_POST["w2"] . " ist $erg";
?>
</body>
</html>
ub11b funktioniert. ub11a liefert folgende Fehlermeldung:
Notice: Undefined variable: w2 in C:\xampp\htdocs\ub11a.php on line 4
Notice: Undefined variable: w1 in C:\xampp\htdocs\ub11a.php on line 4
Notice: Undefined variable: w1 in C:\xampp\htdocs\ub11a.php on line 5
Notice: Undefined variable: w2 in C:\xampp\htdocs\ub11a.php on line 5
Die Summe von und ist 0
Warum??