I build a guestbook so you can say hi to me using PHP
October 4, 2025
I've just rolled out a new guestbook feature for the site. It was a fun, simple project that lets visitors leave their mark. You can sign it from the bottom of any page and view all the entries on the homepage. Here’s a quick technical breakdown of how it works:
§The Architecture
§Backend (PHP)
- The core is a single RESTful API endpoint,
guestbook.php, that handles both GET requests (to fetch entries) and POST requests (to submit new ones). - All entries are stored in a simple JSON array in
files/guestbook.json. No database needed for a project this size. - Server-side validation is in place: initials must be exactly three characters, and the message can be between 0 and 50 characters.
§Frontend (JavaScript)
- A single script,
scripts/guestbook.js, handles all frontend logic. - It performs client-side validation that mirrors the backend rules, giving the user instant feedback.
- Communication with the PHP backend is handled asynchronously using the
fetch()API, so the page never has to reload.
Try it out!!