Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Falsches PHP Skript?

Empfohlene Antworten

Veröffentlicht

Hallo,

ich bin derzeit dabei, mich in HTML/PHP/MySQL einzuarbeiten. Dazu arbeite ich dieses Tutorial durch. In Kapitel "D" geht es gleich am Anfang in einem Beispiel um zwei Dateien, einmal "ud01.htm" mit folgendem Inhalt:


<html>

<body>

Bitte tragen Sie zwei Zahlen ein und senden Sie das Formular ab.<br>

<form action = "ud01.php" method = "post">

    Wert 1: <input name = "w1"><p>

    Wert 2: <input name = "w2"><p>

    <input type = "submit">

    <input type = "reset">

</form>

</body>

</html>

Und "ud01.php" mit folgendem Inhalt:


<html>
<body>
<?php
$erg = $w1 + $w2;
echo "Die Summe von $w1 und $w2 ist $erg";
?>
</body>
</html>
[/PHP]

Installiert ist bei mir zum testen "FoxServ v3.0" auf WinXP, die Dateien liegen im selben Verzeichnis. Rufe ich dann im Browser /localhost/ud01.htm auf und gebe zum testen Zahlen ein, bekomme ich immer das:

[color=blue]Die Summe von und ist 0[/color]

Fehlt da noch irgendwo Code in der .htm oder im php skript?

Original geschrieben von Ibanez


<?php
$erg = $w1 + $w2;
echo "Die Summe von $w1 und $w2 ist $erg";
?>
[/PHP]

[/b]

Lerne lieber mit einem anderen aktuelleren Tutorial, seit PHP 4.1.2 ist eine direkte übergabe von Werten nicht mehr möglich.

Du solltest die Superglobalen Variablen $_GET $_POST ... benutzen.

[PHP]
<?php
$erg = $_POST['w1'] + $_POST['w2'];
echo "Die Summe von $w1 und $w2 ist $erg";
?>

sollte funktionieren.

Gruß Jaraz

PS: Nähere Informationen zu dem Effekt kannst du bei google oder hier im Forum unter dem Stichwort "register globals" finden.

Danke, hat funktioniert. Hier nochmal der Code:


<html>
<body>
<?php
$erg = $_POST['w1'] + $_POST['w2'];
echo "Die Summe von " . $_POST['w1'] . " und " . $_POST['w2'] . " ist $erg";
?>
</body>
</html>
[/PHP]

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.