PHP
  Home arrow PHP arrow Page 4 - Creating a Simple Threaded Discussion ...
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Creating a Simple Threaded Discussion Forum
By: Jacques Noah
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 24
    2006-10-16

    Table of Contents:
  • Creating a Simple Threaded Discussion Forum
  • Index.php
  • viewarticle.php
  • Postre.php

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Creating a Simple Threaded Discussion Forum - Postre.php


    (Page 4 of 4 )

    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.

    <form name="form1" method="post" action="ins.php">
         <input type="text" name="name">
        <input type="text" name="title" value="<? echo "RE: " .
    $_SESSION['title'] ."" ;?>">
     <input name="parent" type="hidden" value='<? echo $parent//"".
    $_GET['parent']. "";?>'>
      </div>
    <div align="center"><a href="index.php">Topic Listings</a>|<a
    href="post.php?parent=0">Post New Topic</a> </div>
    </div>
    <div id="content2">
      <p>
     <center><textarea name="message" cols="75" rows="9"></textarea></center>
    </p>
    </div>
    <div id="footer">
     <center> <input type="submit" name="submit" value="submit"></form></center>

    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:

    function insertsmilie($smilie) {
    $smilie = str_replace(":D", "<img src="imagessmile.gif">",
    $smilie);
    $smilie  = str_replace(":A","<img src="imagesangry.gif" >",
    $smilie);
    return $smilie;
    }

    fns_all.php

    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:

    function badwords_filter($msg)
    {
        $obscenities = file("test.txt");
        $newmsg = $msg;
        foreach ($obscenities as $key=>$val)
        {
            $newmsg = str_replace(trim($val), "XXX", $newmsg);
        }
        return $newmsg;
    }

    Conclusion

    Finally, I would suggest that you create a login script to go with this forum for the admin area.

    Below is an example of an administrators area:

    And this is what we will create next for our forum, in the next article. Till then have fun!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Good tutorial, the system did work, although I would suggest cleaning up your code...
       · Well I do hope that everyone finds my article educational. I also thank you for...
       · Really this code i mean Creating a Simple Threaded Discussion Forum is looks prety ...
       · i am not master in php, but i want to become, i had seen ur post, where can i get...
       · I dont understand how it worked although i did what it told me to do it didnt do...
       · hello, i,m asking where to find the code for the files config.php,Tutstyle.css and...
       · Jacques - interesting article and I'd like to try your solution, but where can I get...
       · I am just starting to dig into the world of PHP development. I was so glad when I...
     

       

    PHP ARTICLES

    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT