Home > Articles > Simple Steps to Build a Custom CMS application Using PHP

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:

 

CREATE TABLE `cms` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`title` VARCHAR( 255 ) NOT NULL ,
`content` TEXT NOT NULL ,
`created_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
`status` TINYINT NOT NULL DEFAULT '1',
`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.

http://ckeditor.com/download
 

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>
</form>

 

PHP code to insert:

 

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

$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:

<?php
$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:

 

<html>
<head>
<title><?php echo stripslashes($title);?></title>
<meta name="keywords" content="<?php echo stripslashes($meta_keywords);?>"  />
<meta name="description"  content="<?php echo stripslashes($meta_description);?>"  />
</head>
<body>
<?php echo stripslashes($content);?>
</body>
</html>
You may also like
Maintenance page for Heroku hosted applications
How to fetch the URL in React.js application
Sending HTML template emails using SMTP in NodeJS
Deploy Node.js application to Heroku

5 Responses

  1. Shyam

    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. Pingback : Top 10 most viewed posts in anil labs - Anil Labs

Leave a Reply

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