Home arrow PHP arrow Creating an Administration Area for a Simple Threaded Discussion Forum

Creating an Administration Area for a Simple Threaded Discussion Forum

Discussion forums usually need an administrator to handle various tasks that you wouldn't want just any forum user doing, such as banning other users. This article, the second of two parts, will show you how to set up an administration area for a threaded discussion forum, and some of the functions you might want an administrator to manage.

TABLE OF CONTENTS:
  1. Creating an Administration Area for a Simple Threaded Discussion Forum
  2. Code
  3. The delall() and deltopic($uid) functions
  4. Database connection, bad words
By: Jacques Noah
Rating: starstarstarstarstar / 6
October 23, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

Following my previous article titled "Creating a Threaded Discussion Forum," we are going to create the administration side of things. Why do we need a administrator? Well, somebody has to manage the forum, and I guess the administrator drew the short straw. On the plus side the administrator can, among other things, ban a user from the forum, delete user entries and even censor the forum to some extend. We are going to implement the following functions:

  • Remove/add certain (bad) words.
  • Retrieve all topics.
  • Delete all topics.
  • Start a new topic.

To follow along with this part of the article you will need access to a MySQL database (created in the previous article) and any version of PHP above version 4.

How the administration area works

Basically, everything is going to be done on one page, which is the "siadmin.php" page. The navigation bar will be on the left with all its links and the main area will be where the outcome of a function will be displayed. The links will all send an action variable, which will be processed by the "switch" function. The action variable will be in a format like this:

<a href="<? echo $_SERVER['PHP_SELF'] ?>?
action=deleteall">Delete ALL Topics</a>

The "$_SERVER['PHP_SELF']" is part of a global array of variables that is available to every PHP script. The PHP_SELF refers to the page on which the code is written. This ensures that the action variable is sent to the siadmin.php page.

The value of the action variable will be handled by the switch statement.  The switch statement has the following syntax:

switch(){
Case "condition1"
Statements
break;
}

Because it can handle a lot of different conditions in a clear and precise way, it is ideally suited to process the five links that we have in our navigation section. I use only one page for the administration because otherwise I would have had to create a page for each function. That would have required far more coding and waste valuable processing power on the server.



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: