[  Home -- Blog -- Reference -- About  ]


Creating a Comment System
-------------------------
I wanted  to add a comment  system to my
page.  Not  because I expect  anybody to
actually  comment,  at  least not  for a
while,  but just to see if  I could make
it work  (within my desire to keep  this
page minimal, and javascript-free).

The basic idea  is to have a form at the
bottom of the page,  with a text box for
the  commenters  name,  and another  for
their comment  (as well as a "Post" but-
ton, of course).  This form would send a
POST request to the server, which should
run a program to take the comment, sani-
tize it, then add it to a file.

When a page is loaded, index.php fetches
the content,  and adds a header and foo-
ter.  If a comment  file  exists for the
page, it will  then also read this file,
and append it before the footer.  Simple
as that!

So far, I have the rendering working. On
the server,  I have a 'public/comments/'
folder,  and inside there are files with
names like 'ref.txt'. 'ref' in this case
corresponds to the page with slug 'ref',
and this  is the  comment file  for that
page.  The file contains the already sa-
nitized and formatted  comments for that
page,  so the contents can simply be in-
serted into the page.

Next step is to implement the program to
receive POST requests, sanitize the con-
tent, and write it to the correct file.


v > Discussion No comments yet. == Add a Comment ==
[ Home -- Blog -- Reference -- About ] ---------------------------------------- 99v.no (c)2026