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:
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'] ?>? 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(){ 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.
blog comments powered by Disqus |