October 20, 2012 4:45 pm

Create a Simple Forum in PHP

Now days people trying to get forums and searching on net free open source forum etc. Today i am going to make a simple script of forum for all of you and its very simple you can easily implement it on your system.







Create bellow 5 files

  1. new_topic.php
  2. add_new_topic.php
  3. main_forum.php
  4. view_topic.php
  5. add_answer.php


Follow these steps

Create table name “fquestions” and “fanswer” in database “myforum”.
Create file new_topic.php.
Create file add_new_topic. php.
Create file main_forum.php
Create file view_topic.php
Create file add_answer.php

Step 1: Database:

Create database “myforum” and make 2 tables “fquestions” and “fanswer”

Step 2: Create file new_topic.php

Step 3: Create file add_new_topic.php

 Step 4: Create file main_forum.php

 Step 5: Create file view_topic.php

 Step 6: Create file add_answer.php

Author Huzoor Bux

I am Huzoor Bux from Karachi (Pakistan). I have been working as a PHP Developer from last 5+ years, and its my passion to learn new things and implement them as a practice. Basically I am a PHP developer but now days exploring more in HTML5, CSS and jQuery libraries.

Tutorial Categories:
  • minD

    can i use this to my system in company?

    • huzoorbux

      @7d1d19d7df4ebe5a46ea2e785d8e36d9:disqus you can use this code and very soon its new version i am going to publish i hope that will also very helpful for you.

      • minD

        thanks… 😀

  • Patricknet


  • Miloue

    Is this the same tutorial that is on phpeasystep?

  • Luke Juriga

    This code is great, however, when i go to respond to a topic I can fill the form out, submit it, and it shows that a comment was added, but when I go and look at the topic no response is shown. All I can see is the original post no comment.

  • Carlos A.


  • brent

    “; echo “View your topic”; } else { echo “ERROR”; } mysql_close(); ?>

    • michael

      me too

  • if this system has one spam code for validation and write IP in DB, will be very good

  • sss

  • ccc

  • nice conversation

  • fdfffff

  • Kyo Kusanagi

    this forum sux … no threads, no pagination, no security or atleast required fields checkup.
    i expected some effort into this script since you call yourself PHP developer.
    Looks more like a comments section rather than a forum.

    • que


  • Livaco

    i got this when i try and post somthing “ERROR”

    • Livaco

      I Also Got This On main_forum.php “Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/u404949692/public_html/main_forum.php on line 31”

  • bernard

    wow… this is so outdated… even for a 2012 article … my opinion : Google should review their algoritm by comparing their search results with the php deprecated functions list … lol

  • rk


  • ameer nagvenkar

    cannot add more then one answer to a question

  • ameer nagvenkar

    cannot add more then one answer to a question

  • Sakhawat Hossain

    I cannot daily attendances php & mysql any body help me & send source code my email : [email protected] Pls …………..

  • Thank you so much Huzoor Bux! I was searching the reply coding for my project as to how to implement and your coding worked! 🙂

  • Adrian Smith

    What should I add for localhost? The web server host name?

  • Tariq Tahiri Bux Mahesar

    thank you sir ; jo apne ye plugin lagai h esa system hum khud nhi bana skte hain ????? reply p reply

  • Aas Hack Exe

    شكر لك

  • Aas Hack Exe

    Upload the image to the database and view it???????????????