How to Build Your Own Web Content Management System
Instructions
-
-
1
Create a database. This is where all the login and data information will be stored. Such a database would include setting up a customer's table and other information. Using a database will help you to organize information logically, rapidly gain access to it, manipulate and change it whenever needed and automate common tasks more easily.
-
2
Create a class for accessing the database. Such a class will tell the program to grab data and components from a system component and provide access to it. The example below shows the functional approach in using such a class:
Class: DbConnector
// Purpose: Connect to a database, MySQLrequire_once 'SystemComponent.php'
GO
class DbConnector extends SystemComponent {include variables here
}
function DbConnector(){$user = $settings[‘dbusername’]
GO
$pass= $settings[‘dbpassword’]
GO
}
function query(){code goes here
}
function fetchArray(){code goes here
}
function close(){
mysql_close()
GO
}The above code shows the main parts of the database and how to connect and retrieve data from it.
-
3
Create a validator class for security. A validator class checks for errors in user input and will either display an error or allow a user login if it is safe and correct. An example of such a class written in PHP is shown below:
<?php
require_once ‘SystemComponent.php’
GO
class Validator extends SystemComponent {var $errors
GO
}
?>The above code stores a list of error messages.
-
4
Write a class to secure the site. The function for doing this is shown below:
Function logg(){
session_start()
Header(“cache-control: private”)
GO
}function logout(){
unset($this->userdata)
GO
session_destroy()
GO
exit()
GO
} -
5
Create the interface design. This is graphical part of the site with the login information as well as other additional information generally appearing on the homepage.
-
6
Create the help and documentation for the system to address the most common tasks a user will need to perform.
-
1