5

A Beginner’s Guide To Building A Simple CMS

buildingCreating and maintain a web site is not a hard job today especially at a time when the full-proof and automated content management systems are so widely available. However, creating a simple CMS is also not much of a tough task. Here is the simplified and step by step guide for first time PHP users for the creation of their first CMS.

Building the Class

In order to lay a foundation for your first content management system, you simply need to build a class in the file named “simpleCMS.php”. Once the class has been created, add four variable namely host, username, password and table. In other words, try to create one class with five methods and four variables. To bring out a cleaner code especially in a project as large as creating an entire CMS, try opting for the PHP’s object oriented approach.

The Variables

All the four variables created under the class are actually used in connecting the database. $table, $username, $password and $host provide an access and path to the database on the specified server. The database is further constructed through the method buildDB ().

Building the Database

The function buildDB () is always declared as private in to the parent class. Such a function usually runs a MySQL command which further checks the generated database so as to confirm if ‘testDB’ exists. If the performed check is positive, the function would pass on a notification terming “success”. In case the result is negative, it will create a table and will further assign three columns to it in order to hold the unmatched data.

Connect the Database

We have already created a function which will build our table. It’s now time to create one that will connect it to the database. In order to so, we call two functions. The first one being mysql_connect() that will simply hook the database and the other one being mysql_select_db() that will save all the data in the appropriate place. However, the connect () function is used to connect further to the database and run the buildDB () function. Also, you must make sure that you are in no way overwriting the entire database every time you tend to load the page so as to call the specified functions.

Build the Form

Now the database has been created and you need to put relevant stuff into it. Use the form element in order to declare the function. In order to reference the file which is currently in usage, try adding an extra $_SERVER['PHP_SELF'] variable in the action attribute of the current form element. This will help in serving as a shortcut and is highly beneficial if you are planning to reuse your code for each page on a different website as it will save the trouble of rewriting.

Saving the Data in the Database

The write () method is employed to save the data in the existing database. Put a variable $p in to the function call which will hold the entire information that has been earlier sent from the form through the past method. Also, make sure that you check all the variables before saving the entire database so that they are not left blank. Once the variables have been set, you should then try to set the variable $ created with the existing Unix Timestamp. This will aid in the sorting of the entries in a chronological manner whenever you will try to view them in future.

Displaying the Information in the Database

In order to get the information back out from the generated database, we make use of the display_public () method. This is indeed one of the most complex methods employed in the creation of simple content management systems. Therefore, you might try and ask for a little savvy help on the same in case you are unable to understand anything.

GD Star Rating
loading...
A Beginner’s Guide To Building A Simple CMS, 1.0 out of 5 based on 1 rating
Opt In Image
Sign-up To Our Newsletter....
...And Get This FREE eBook!
  • Understand the phenomenon behind Google Sitelinks.
  • Increase the visibility and popularity of your Website.
  • Find out how you can improve the link structure of your site.
  • Determine how to put your Website on the Google Sitelinks map.
  • Learn how you can use Google Sitelinks to get more targeted-SEO traffic to your Website.
Filed in: Design, Tutorial Tags: , , , ,

Get Updates

Share This Post

Related Posts

5 Responses to "A Beginner’s Guide To Building A Simple CMS"

  1. Anamika
    Twitter:
    says:

    nice article Jack,
    nice information about building your own CMS..,
    but i don’t think if any body want to start a website have to do the same because there are many CMS in the internet, like WordPress, tumblr etc..
    by the nice article from the programming point of view..:)
    Anamika recently posted..Download Iron man Game for AndroidMy Profile

    GD Star Rating
    loading...
  2. myles
    Twitter:
    says:

    Building own CMS is a good idea, but what is the need t build one, when we have the most brilliant WordPress. One can customize it to it’s very own use. And also it a open source too.
    myles recently posted..What is Cydia | What does Cydia Do | Complete [Tutorial]My Profile

    GD Star Rating
    loading...
  3. Sudipto says:

    hey Jack,
    Nice post and thanks for sharing this post but I totally agree with Myles that why we build CMS when we have wordpress.
    Sudipto recently posted..Best Android Phone Under 10000My Profile

    GD Star Rating
    loading...
  4. Dan says:

    This is a nice tutorial if you want to build a basic, custom CMS. But in most cases it’s not worth the effort because there are a lot of useful, fully customizable CMS on the Internet like WordPress, Joomla etc.

    GD Star Rating
    loading...
  5. John says:

    It could be easy to build a CMS but i think, it will not be so easy to go on the top in such a competitive time.

    GD Star Rating
    loading...

Leave a Reply

Submit Comment

CommentLuv badge

This blog uses premium CommentLuv which allows you to put your keywords with your name if you have had 7 approved comments. Use your real name and then @ your keywords (maximum of 2).

© 2014 TechSling Weblog. All rights reserved.
Designed by TechSling Online.