One of the most important features of modern web applications is the ability to allow users to interact via a commenting system. Nearly every blog in existence allows its readers to comment on entries. This adds to the experience of the users and the blog author by enabling everyone to continue the conversations the author initiates with his posts.
In this chapter, I'll show you now to add a commenting system to the blog. To get the system up and running, you need to do the following:
Create a comments table in the database to store comment entries
Build a Comments class to perform all comment-related actions
Build a method for displaying a form to enter new comments
Modify index.php to display the comment form
Build a method to store comments in the comments table
Modify update.inc.php to handle new comments
Build a method to retrieve comments for an entry
Modify index.php to display entry comments
Build a method to delete unwanted comments
Modify update.inc.php to handle comment deletion
We'll be using object-oriented programming in this chapter again, so if you need to, refer to Chapter 8 for a quick refresher on the basics.