Simple Steps to Build a Custom CMS application Using PHP

In this post i would like to build a Simple Steps to Build a Custom CMS application Using PHP and Mysql. We will pulling data ( content ) from mysql and displayed in the nice formated way to display in the front-end section. And Content is manageble by admin section by WYSIWYG editor.

Simple Steps to Build a Custom CMS application Using PHP by Anil Kumar Panigrahi

Simple Steps to Build a Custom CMS application Using PHP by Anil Kumar Panigrahi

Database Table format:


`title` VARCHAR( 255 ) NOT NULL ,
`content` TEXT NOT NULL ,
`created_by` VARCHAR( 255 ) NOT NULL ,
`modified_by` VARCHAR( 255 ) NOT NULL ,
`modified_date` DATETIME NOT NULL ,
`meta_keywords` TEXT NOT NULL ,
`meta_description` TEXT NOT NULL

WYSIWYG(What You See Is What You Get) editor:

We have many editors. For this example i am taking CKEditor.We can download the editor form the below url.

HTML code:

Insert format:

<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script src="js/sample.js" type="text/javascript"></script>
<link href="css/sample.css" rel="stylesheet" type="text/css" />

<form method="post">
<div>Title : <input type="text" name='title' /></div>
<div>Meta Keywords <textarea name='meta_keywords'></textarea></div>
<div>Meta Description <taxtarea name='meta_description'></textarea></div>
<div>Content <textarea name="content" class="ckeditor"  id="editor1" rows="30" cols="70"></textarea></div>
<div><input type="submit" value="Submit" /></div>


PHP code to insert:


$query = "INSERT INTO CMS (title,meta_keywords,meta_description,content,created_by,created_date,status) VALUES  ('".addslashes($_POST['title'])."',

$result = mysql_query($query);


UPDATE Query :

get the details with using stripslashes function.

 mysql_query("SET NAMES 'UTF8'");
 $cms_content_query="UPDATE cms SET content='".addslashes($content)."' , modified_by='".$_SESSION['uname']."' , modified_date=now(), meta_keywords = '".addslashes($_POST['meta_keywords'])."', meta_description = '".addslashes($_POST['meta_description'])."' WHERE id=".$id;


Front-End Application.


PHP Code:

$query = "SELECT title,meta_keywords,meta_description,content from cms where id=1";
$result = mysql_query($query);
$get_cms_details = mysql_fetch_array($result);


HTML code:


<title><?php echo stripslashes($title);?></title>
<meta name="keywords" content="<?php echo stripslashes($meta_keywords);?>"  />
<meta name="description"  content="<?php echo stripslashes($meta_description);?>"  />
<?php echo stripslashes($content);?>

Anil Kumar Panigrahi

With more than 10 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online ... Contact : [email protected]

You may also like...

5 Responses

  1. Shyam says:

    This tutorial is not showing the last two lines of code in php code section and html code section(Absolutely at the end of the post). please correct that.

  2. Nerudo says:

    Awsome stuff. Im not sure if its just me but I cant vew the PHP Code fro the Front end Application and the HTML CODE.

    Awsome blog awsome stuff. Thanks very much

  3. Deus Mateo says:

    How about adding JavaScript to the php code. This applies mostly to web browser miners that need to embed miner scripts to their websites

  1. January 8, 2012

    […] MySql and PHP  Steps to implement and hosting your website in google app engine for free  Simple Steps to Build a Custom CMS application Using PHP  How to implement graphs using fusion charts and php  How to manage random header image […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.