HomePHP Page 4 - Creating a Simple Threaded Discussion Forum
Postre.php - PHP
Most websites have some method of interacting with a visitor. Some have a chat system and others have shoutboxes or other ways to attract the visitor to return. One of the most used methods is a discussion forum. And this is what we are going to create and discuss in this article (the first of two parts).
This page enables you to reply to a specific thread. The thread number is passed on from the viewarticle page. Here we create a form and populate its title field with the $_SESSION['title'] variable.
Once submitted, the form values are processed in the ins.php page and then inserted in the database.
post.php
This page is for new posts; it will send the form data off to the insert.php page, which will process and enter the details into the database.
And by the way...I've just created this function as something additional. The function will enable you to add... wait for it... smilies! All that the function does is to search for the ":D" or the ":A" delimiters and then replace that text with the images that has been assigned. You can extend this function by adding your own images and delimiters later on, to give your users a wider choice of smilies. Here's the function:
The script contains all the functions used throughout the application. I've already explained the main function called gettopics() and what it does. There is another function that I think needs a bit of explaining, the "badwords_filter($msg)" function. This function does exactly what its name implies, it replaces offensive words in a message that is posted. It is used in the ins.php script. It retrieves a list of bad words stored in a text file and then checks to see if any of them are included in the newly posted message. If it finds one, it replaces that word with XXX. Here's the code that does the job: