Create CMS Using PHP with SEO Friendly URLs

By | June 18, 2017


Hello friends today’s tutorial is all about Create CMS Using PHP.  CMS stands for Content Management System. CMS is very useful for creating Blog or Website. Basically CMS is used for managing content dynamically. CMS is used widely and many CMS are already there in the market like WordPress, Drupal, Joomla etc they are big and having many features which we dont want in our application or website. So we create our CMS according to our need. In this tutorial we will create the CMS using PHP with SEO Friendly URLs.

In this tutorial We will create front end and admin end so we will start with the Admin end first.

Admin Panel

  1. Dashboard (dashboard.php)
  2. Add Page (add-page.php)
  3. Edit Page (edit-page.php)
  4. Manage Page (manage-page.php)
  5. Login Page (index.php)

Admin Panel Directory Structure

  1. admin
    • functions (Directory)
      • connectionClass.php
      • gump.class.php
    • inc (Directory)
      • header
    • login (Directory)
      • loginClass.php
    • messages (Directory)
      • alertClass.php
    • pages (Directory)
      • pageClass.php
    • add-pages.php
    • dashboard.php
    • edit-pages.php
    • index.php
    • logout.php
    • manage-pages.php

 

Front End

  1. Index Page (index.php)

Lets start with Step by Step.  First we will start with creating the login script with login page.

Login Page (index.php)



Above code will create a login window. We use the username and password for login. After clicking submit we will go for checking the submitted values.

Username – admin

Password – demo

loginClass.php – We will use this class for check login and save the session values for maintaining the login.

In the above code first we will sanitize the values using the mysqli_real_escape_string function.  After getting the values we will first check the Username if we will find it than we will move for checking the password. If everything goes perfect than we will save the values to session and redirect the page to the Dashboard.php.

Dashboard (dashboard.php)

This page is just a welcome page and for showing the counting of how many pages you have added. This page will come when you successfully login.

 Add Page (add-page.php)

We will use this page to add new pages to our website. In this we have use some text boxes so that it will helpful for us to enter the data to the database.

We have used the summernote as editor for adding the page details.

We have used the gump class so that we will validate the form before submitting the form.

Manage Page (manage-page.php)

This page will list all the added pages for edit and delete. This page will show the data in table format.



Edit Page (edit-page.php)

Edit page will work same as add page it will just take the values from Get global variable and show the values in the text boxes. When you click on the update it will update the current data.

Delete Page

Deletion of page is available at the manage-page.php. In the Action column you will find a link named Delete. When you press the button you will see a warning for confirmation if you press “Yes” It will delete the page.

 

Front End

As you can see We have created the Login page, Add page, Edit page, Manage Page, Delete Page functions. Now we will move to our Website Front end. Its so simple and easy. You have to just show the data from the Database using the Page Class.

We will call all the pages over the index.php and show the details according to the pages clicked. Here we can call the data by using 2 types. 1 Calling by Id 2. Calling by URL.

Calling by id will work if we use the page links as Id in our navigation like-

But this is not the approach we are using. We are working over the SEO Friendly URLs and this is not the Seo friendly at all. So we will change the ID to the URL and remove the index.php from the URL. Our Navigation will look like this than.

For doing this we will create a .htaccess file with some lines of code

.htaccess

First be sure that rewrite is enable in your server otherwise it will not work. We have used the RewriteBase as /cms/ you can use anything here you want but it should be the name of your Folder like i am having –  http://tutorials.vivekmoyal.in/cms/what-is-lorem-ipsum

If you dont have any folder than you can remove it also. Now here is our website index.php page for showing all the information.

index.php

We are using a function  – particularPageSlug($pageList[0][‘URL’]). This function will take the data from the database based on the url parameter value. You must be missing some files here so you can download it form our my Github repository.

Download From Here

Demo

 

16 thoughts on “Create CMS Using PHP with SEO Friendly URLs

  1. Vishal Rana

    Nice project but I need something different – This is not SEO friendly.

    I need:-
    Like-
    I have three categories on my blog – HTML,CSS ,JS
    I write the article –
    So the URL should be like –

    for PHP –
    localhost/php/what-is-php

    for CSS

    localhost/css/where-i-can-learn-css

    for JS articles URL
    like –

    localhost/js/where-i-can-learn-js

    I need this type for SEO friendly URL –

    localhost/category_name/title_slug

    Please help me and change it –

    share the best solution for that. It will be best for SEO.

    Reply
  2. sanana sanu

    i am download code and use on local at xammp following error occur
    Warning: Use of undefined constant pid – assumed ‘pid’ (this will throw an Error in a future version of PHP) in C:\xampp\htdocs\cms\index.php on line 7

    what is solution for local …

    Reply
  3. Ricco

    Hello, is it possible to change the connection for include my db settings
    my db connection File db.php looks so :

    ob_start();
    $db['db_host'] = "localhost";
    $db['db_user'] = "xxx";
    $db['db_pass'] = "xxx";
    $db['db_name'] = "xxx";
    
    foreach($db as $key => $value){
        define(strtoupper($key),$value);
    }
    
    $connection = mysqli_connect(DB_HOST,DB_USER,DB_PASS,DB_NAME);
    
    Reply
  4. Pingback: Create CMS in PHP - SEO Friendly URL - Part - 6 - Semalt - Coding Videos

  5. ASHUTOSH SHUKLA

    Error found:
    Notice: Undefined index: pid in C:\xampp\htdocs\com\php-cms-master\cms\index.php on line 13
    Menu was showing page not found error after clicking it.
    Resolve as soon as possible I will be highly greatfull to you.

    Reply
    1. Vivek Moyal Post author

      Check your htaccess file. If you are using on local than you will face this issue. Over the server check the htaccess file it will surely work for you

      Reply
      1. ASHUTOSH SHUKLA

        On server getting error : The requested URL /why-do-we-use-it was not found on this server.

        Reply
        1. Vivek Moyal Post author

          I m sure your htaccess is not working properly if you are getting 404 not found error

          Reply
  6. Alfredo

    Hi,
    congratulations !

    i downloaded the code but i didn’t find de database structure,
    can you send it to me, please ?

    many thanks.

    Reply
  7. maksdjab

    I liked your cms but in the archive I found the sample Database.
    Thank you!

    Reply
    1. sanana

      Warning: Use of undefined constant pid – assumed ‘pid’ (this will throw an Error in a future version of PHP) in C:\xampp\htdocs\cms\index.php on line 7

      how to fix

      Reply
      1. Vivek Moyal Post author

        This is warning regarding the pid variable. It is due to declaration you can update it by proper declaration

        .Sometime when we use the variable and it is not properly declared then it shows this error.

        Reply

Leave a Reply

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