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.

Textdatei auslesen und später String hinzufügen

Empfohlene Antworten

Veröffentlicht

Heyho =)

Habe nicht viel Ahnung von PHP, wollte mich allerdings mal einarbeiten.

Habe mich im Netz schlau gemacht, was es so für Möglichkeiten etc gibt und stehe nun vor einem Problem.

Mein Skript soll den Inhalt einer Textdatei auslesen und ausgeben. Unter dem Text soll ein Formular sein, wo man einen Text eingeben kann, welcher dann durch einen Klick auf einen Button in die Textdatei eingefügt wird (in eine neue Zeile). Danach soll die Textdatei erneut ausgelesen werden, damit der hinzugefügte Text auf der Seite angezeigt wird.

Das Auslesen klappt soweit, allerdings schreibt das Skript nichts in die Textdatei rein.

Hier der Code (nicht sehr umfangreich ^^)


<?php

$Inhalt = file_get_contents("test.txt");

echo "$Inhalt";


if(!isset($ausgefllt))

{

?>


<table width="46%" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td>

	<form name="form1" method="post">

        <table width="338" border="0" cellspacing="2" cellpadding="2">

          <tr>

            <td align="right" valign="top">

			<font size="2">Nachricht</font></td>

            <td>

              <textarea name="Nachricht" cols="40" rows="8" class="inputtextarea"></textarea>

            </td>

          </tr>

          <tr>

            <td> </td>

            <td>

              <input type="submit" class="inputbutton" value="Absenden">

              <input name="ausgefllt" type="hidden" id="ausgefllt" value="1">

            </td>

         </tr>

        </table>

		</form>

     </td>

  </tr>

</table>

<?php

}


else

{

$Bytes = file_put_contents("test.txt", $Nachricht, FILE_APPEND);

}

?>

Hat jemand eine Idee, was ich falsch gemacht habe o.ä.? Danke im Voraus =)


if ( !function_exists('file_put_contents') && !defined('FILE_APPEND') ) {
$Bytes = file_put_contents("test.txt", $_POST['Nachricht'], FILE_APPEND);
}
[/PHP]

wenn man das formular absendet muss man die variablen richtig ansprechen

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.