Trivial local notes with PHP

June 10, 2023 - Reading time: 2 minutes

Post notes to you local network server.

Here is the PHP and other files needed.

Do not put this on the internet!


Form to post a note.

<form action="note.php" method="post">
<input type="text" name="name" size="40"/>
<textarea cols="80" name="message" rows="20"></textarea>
<input type="submit" value="Post note" /></form>


File to which notes will be appended to. Make sure the server can write to this file.



Script that will write the note.

$file = dirname(__FILE__).'/notes.html';
$entry = '<hr/><p><h3>'.date('Y-m-d H:i:s').'</h3><h4>'.$name.'</h4><pre>'.$message.'</pre></p>'.PHP_EOL;
$ret = file_put_contents($file, $entry, FILE_APPEND | LOCK_EX);
header('Location: ./notes.html');