The function below sets the database connection details: function forumdb(){ Remember to add your connection details to the this function. This function shows a form that will enable you to enter a word that you want banned from the forum. function showfrm(){ Here's what the form looks like:
Fig. 3 The form is presented when you want a new word to be added to the banned word list. The "getword()" function retrieves all the banned words: function getword(){ The function interacts with a text file on the disk and uses PHP's very handy file handling functions to retrieve a list of banned words. Here's a screen shot of the above function result:
Fig. 4 A list of banned words. The writeword() function writes all the words to a file called "badwords.txt." function writeword(){ As I mentioned before we will use a $action variable to receive the value passed from the link that has been clicked, and then use the switch command to handle the value accordingly. Here's a snippet of the switch command: if(isset($_GET['action'])){ As the code above shows, once the user clicks on the "get all main topics" link the "getall();" function is called. The same thing happens when the user clicks on the "Delete all topics" link; the "delall()" function is called. Conclusion That's it for the admin section of the forum. Here are a few suggestions to improve its performance: create a table to store the "bad words." This will enable you to add/remove words more easily than you would with a file-based system. Try to set up a login script to control access to the admin area, as I'm sure you would not want just anyone to have access to the functions on that page!
blog comments powered by Disqus |
|
|
|
|
|
|
|