PHP
  Home arrow PHP arrow Page 4 - Creating a Simple Threaded Discussion Forum
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
PHP

Creating a Simple Threaded Discussion Forum
By: Jacques Noah
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 29
    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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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!



     
     
    >>> More PHP Articles          >>> More By Jacques Noah
     

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek