Comment System!

Summary

Wanted to add the ability for people to comment on this website, but delayed adding the feature until I could write the code myself. There are many pre-built PHP solutions on the market (like commentator), but the original purpose of this site was to allow me to learn how to build a website from scratch. So I've implemented the comment system using about a hundred lines of code to access the MySQL database, verify inputs and display all the comments for a particular article.

Wanted to add the ability for people to comment on this website, but delayed adding the feature until I could write the code myself. There are many pre-built PHP solutions on the market (like commentator), but the original purpose of this site was to allow me to learn how to build a website from scratch. So I've implemented the comment system using about a hundred lines of code to access the MySQL database, verify inputs and display all the comments for a particular article.

For those that care about the more technical details. Use form, input, and textarea tags to make the user form. When the page is rendered, check for GET or POST variables to see if someone has submitted a comment, e.g. isset($_POST["comment"]). If so, get the comment information, check its validity, and then insert it into the correct MySQL database and table, e.g. using mysql_query("INSERT INTO..."). Each comment is associated with the article id, its own special ID and a UTC time stamp. The MySQL database is queried on page load to see if an article has any comments, e.g. mysql_num_rows( mysql_query("SELECT...") )>0. If so, get information for each comment, format the html and send to the user. All this is done at the end of the page, so that the user gets the full article and then the comments start to load, preventing long load times of the MySQL queries or anything else takes longer than normal.

The comment system is only missing a CAPTCHA form to prevent spammers and it will be complete.

Edit: A CAPTCHA system has been implemented and is ready to use.

-biafra
bahanonu [at] alum.mit.edu

other entires to explore:

on the subject of something: reviving an old website
12 may 2015 | website

On the Subject of Something was my original blog during high-school and early college. My Opera (the site it was hosted on) closed down and[...] I was unaware of this fact during the grace period during which they allowed users to export the content from their website. However, I am extremely grateful to the Internet Archive: Wayback Machine, which allowed me to recover many of the webpages. I've included links to all the relevant posts that I could recover. Enjoy!

why we need more james polks
25 september 2012 | politics

James J. Polk expanded the territory of the United States by about one-third during his tenure. A remarkable feat. Not only that, but i[...]t was done through an astonishing three ways: territorial conquest, gold and negotiation.

Some thoughts on why we should demand less rhetoric and more pragmatism/details from our presidents.

week 3 | up and away
02 july 2012 | singapore

Allowed a bit of a breather this week, but nonetheless still full of adventures: getting an equivalent of Montezuma's revenge (but still tr[...]udging on), visiting the awesome Mustafa Indian centre, a trip to Malaysia, biking and plenty more. Let's dive in.

wary statistics #1: the tale of cdc mortality
06 april 2020 | statistics

I will briefly discuss properly interpreting data you might see in the mainstream or on social media. The takeaway: if recent data for some[...] measure (e.g. pneumonia deaths) from this year looks to be different than prior years, make sure to check that it is not an artifact of data collection or compilation.

©2006-2024 | Site created & coded by Biafra Ahanonu | Updated 17 April 2024
biafra ahanonu