HomePHP Using Code Igniter to Enable Comments in a Blog Application
Using Code Igniter to Enable Comments in a Blog Application
Welcome to the fourth episode of the series entitled “Building a Blogger with the Code Igniter PHP framework.” Comprised of seven approachable articles, this series steps you through the development of a blog application using this friendly – yet powerful -- PHP framework. We include copious code samples to demonstrate how to use the MVC pattern to develop a real-world program.
If you have followed the series this far, then you know that the real-world application we're developing is a MySQL-driven blog application. Thanks to the Code Igniter PHP framework, we should be able to develop this application in a relatively short time, without having to spend long hours writing complex classes and functions.
Now that you have been introduced to the main goal of this series, it's time to recapitulate what we covered in the last article. In that particular tutorial, I explained how to build a blog controller class that was charged with displaying on screen a bunch of blog entries, along with their corresponding comments, previously stored on a pair of MySQL tables.
In truth, this last process was performed in a pretty simplistic way, since I recreated a hypothetical scenario in which a few comments were already inserted into one of these MySQL tables. I hope that helped to demonstrate how the controller in question embedded this data into a view file for display purposes.
A decent blog application, however, must provide users with a mechanism that lets them post their comments easily, and the simplest way to do this is via an HTML form. Therefore, in the next few lines, I'll be explaining how to modify the controller class and the comments view file created in the preceding article to incorporate a basic web form that permits users to post comments on a particular blog entry.
Now, it's time to get rid of the preliminaries and see how to improve the functionality of this blog application by letting users to submit their own comments. Let's jump in!