Recently I have created guestbook, thought I share my recepie with you, I made it with ChatGPT 3.5 and very little knowledge of JS and PHP.
Enjoy Readingš
A Simple Guestbook Will Need Html, CSS, JS, and PHP.
Youāll need a simple HTML page with CSS styling and use JavaScript to handle the form submission and save the data to a feedback.json file. Since JavaScript running in a browser cannot write directly to the local file system for security reasons, weāll use a server-side script to handle the data storage. For this example, weāll use PHP to write the data to the feedback.json file.
The following code will give user frontend to submit input in website:
Also you need to link js file into html index file.
This is JavaScript file. It the engine which will make the magick of processing input action happen.
If you noticed I made sure the script have sufficient security features against input injection and XSS vulnerabilties implemented, You can further add your own protective measures for increased security.
The Following php code will store the user input in JSON file.
Now until this point we have done but if you still insist Lets go two step further and add notification system so youāll be notified via email whenever someone sign your guestbook.
Create notify.sh script
Youāll need some mechanism to watch for changes in feedback.json file and triggers the execution of notify.sh
guestbook_Listener.sh
entr is the unix program that listens for file changes and execute commands when changes occur to file.
Now you can make this guestbook_Listener.sh file run in the background in various way.
One I used here is with systemd user services.