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

additional articles to journey through:

justifying hyphens
21 october 2012 | website

Justified text is awesome. Clean lines align well with other elements and it doesn't produce a crazy jagged edge. But without hyphens, prob[...]lems quickly arise. Some lines have super large spaces between words and the end look is quite ugly. There are several solutions: css, server-side, and javascript.

¿qué es la calle?
24 may 2013 | short story | spanish

Había terminado y salé para mi cocina. Tenía hambre pero este día no había comida dentro de mi despensa. Me fui y caminé hacienda[...] la Tport—una máquina que puede transportar una persona a otro lugar sin energía y tiempo. Cuando entré la máquina, toqué algunos botónes y esperé. Pero nada ocurrió y lo hice las mismas acciones otra vez—y nada ocurrió.

How would the disappearance of streets affect the social fabric? This short story briefly (in castellano!) explores a world in which instantaneous, free transport is possible. Meant mainly to practice my spanish, i plan to follow-up with a more detail story in the future.

Campaign Poster 2016 No. 6 | Americans Edition
18 November 2016 | designs

This is an updated version of Election poster no. 6 with a focus on Americans instead of President-elect Trump. Will likely do a continuing[...] series of these posters. Description of previous copied below.

Assuming a President Trump, this is a 3-for-1 future retrospective with a style reminiscent of some older presidential posters.

Those who listen to Trump's full speeches/interviews or read his books get a dose of his boundless optimism mixed in with his more pessimistic views about the current state of the Union. Given his current run of policy speeches, focused the poster on the former trait.

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.

©2006-2025 | Site created & coded by Biafra Ahanonu | Updated 21 October 2024
biafra ahanonu