PHP User comments system

In this tutorial, we’re going to build a system to allow users to add comments to the bottom of your web pages, which is becoming more and more popular lately for a variety of different applications. For example, blogs are now starting to allow users to add comments so readers can join in the discussion, and tutorials have comments sections where users can add their own notes, or comment about the brilliance of your writing for example. The system could also be used to create a guest book application for a site; in fact the principles can be used for pretty much any system which allows users to add data.

We first build a page that allows the user to add comments, which are then stored in a table in a MySQL database. We place the MySQL connection parameters in an include file, so they can easily be added to any page which uses the database, without having to retype them each time, and so they are easily changeable in future if you change servers for example.
 
We then create a PHP include file which can be added to an existing page to show the relevant comments from the database for that particular page. 
$2.79
- OR -

Overview

Table of Content:

  • Step 1 – Creating the Database
  • Step 2 – Creating an include file to hold the Database Connection Parameters
  • Step 3 – Creating a page to allow users to add Comments
  • Creating the HTML
  • Creating the JavaScript
  • Adding the PHP Code
  • Step 4 – Creating a PHP include file to Display the Comments
  • Creating an HTML Layout
  • Creating the PHP Code
  • Step 5 – Adding Comments to an Existing Page
  • Summary

Gareth Downes-Powell

Gareth Downes-PowellGareth has a range of skills, covering many computer and internet related subjects. He is proficient in many different languages including ASP and PHP, and is responsible for the setup and maintenance of both Windows and Linux servers on a daily basis.


In his daily web development work he uses the complete range of Macromedia software, including Dreamweaver MX, Flash MX, Fireworks MX and Director to build a number of websites and applications. Gareth has a close relationship with Macromedia, and as a member of Team Macromedia Dreamweaver, he has worked closely in the development of Dreamweaver, and was a beta tester for Dreamweaver MX.


On a daily basis he provides support for users in the Macromedia forums, answering questions and providing help on a range of different web related subjects. He has also written a number of free and commercial extensions for Dreamweaver MX, to further extend its capabilities using its native JavaScript API’s or C++.


As a web host, Gareth has worked with a range of different servers and operating systems, with the Linux OS as his personal favourite. Most of his development work is done using a combination of Linux, Apache and MySQL and he has written extensively about setting up this type of system, and also running Apache and MySQL under Windows.

See All Postings From Gareth Downes-Powell >>

Reviews

Be the first to write a review

You must me logged in to write a review.