Build a Custom CMS Using PHP and MySQLi: New Plus Tutorial
plus

Build a Custom CMS Using PHP and MySQLi: New Premium Tutorial

Download Source Files

In this video tutorial, we’ll be building a custom Content Management System (CMS) using PHP and MySQLi. We’ll start off by pulling our content from a MySQL database and then build a CMS admin panel to manage our content. For easy content management, we will be using TinyMCE as our editor. I hope you enjoy the screencast. Join today!

Full Website
Admin Panel

Join Tuts Premium

NETTUTS+ Screencasts and Bonus Tutorials

For those unfamiliar, the family of TUTS sites runs a premium membership service called “Premium”. For $19 per month, you gain access to exclusive premium tutorials, screencasts, and freebies at nettuts+, psdtuts+, audiotuts+, and vectortuts+! For the price of a pizza, you’ll learn from some of the best minds in the business. Join today!

  • Subscribe to the NETTUTS RSS Feed for more daily web development tuts and articles.


Tags: Premium
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • John

    glad that I just joined the + section :)

  • Morten Najbjerg

    Isn’t time is better spend learning existing cms’ instead of trying to build your own? Of course You learn some basics – but still.

    Has anyone had customers where this made sense?

    Great idea having a tutorial about TinyMCE though. It’s really a great WYSIWYG.

    • mathew

      I agree people should just learn to use existing cms’s instead of reinventing the wheel.

      • http://www.nickbrowndesign.com/ Nick Brown

        really?

        Why don’t we all just use templates for our websites instead of designing them from scratch.

        Because not only does a custom product address the exact issues and needs of the client, but we learn a great deal in the process of building it.

        I’ve worked with people who spent all their time in pre-built CMSs and many were like fish out of water when a project called for use of a different CMS or a custom solution.

      • Travis

        I agree with you Nick Brown, I know how to design and know how to build the backbone of the site (PHP, MYSQL(i), JS), but never learned CSS so its always a fun for me to take projects that require both. I may not learn anything more than I already know PHP and SQL wise, but I always learn something via CSS.

    • http://panorazzi.com wooncherk

      That depends… what we learn from building a CMS might apply to other applications as well (provided this tutorial is a good one).

      Many people like to learn the ways to do things… instead of just USING it… they like to know how it’s done…

    • http://www.jeff-way.com Jeffrey Way

      That’s like saying, “Why would I convert my PSD when I can pay a company to do it for me?”

      …to learn how to do it!

    • Rik Girbes

      I have had 3 customers wich wanted there own CMS-System… wich i had to make…
      So i Do think that this is a Great subject to make an tutorial for

      Ofcourse learning an already existing cms most of the times is good enough, But, for companies/people who want for example there own user system or so, this isn’t always possible with ‘non-cusom cms systems’.

      nevertheless, Nice tutorial, Thanks!

      Rik

    • john

      This type work is a very need tutorial. Sure you can get a site running with a CMS that is already out there, however, the problem is that most of them are to complex for a business to keep going. The whole point of a CMS is so a company can manage the content not the developer/designer. So often times the less feature rich more custom tailored application works best.

      Expression engine comes the closest for me because you can define your own weblogs to be anything (what forms fields should show up and the name) , but still often times something more custom tailored is needed. I don’t have a plus membership but if done right this can be a great tutorial. “how to build a custom CMS, tailored to a clients business needs and work flow”. If it is how to make something like wordpress (ie. one solution fits all) then those do already exist.

      • Fynn

        I agree.

        I have used Joomla and created my own templates. Added some components and changed their workings a bit by messing with CSS and PHP, which worked pretty all right.

        Thing is, I’m afraid using it for real clients because I don’t have total control over it. I mean, what if the client wants some small changes and I have to tell him/her that I don’t know how to do it…

        I think that’s why a lot of beginning guys like me (at least I am) are afraid of using open source CMS’s and do want to reinvent the wheel. To get an understanding of the basics and to have total control of what you’re making. Also, I agree with John that most CMS’s are way to complex for most projects.

        Besides, I often get the feeling that the people that are promoting those CMS’s most, are excellent webdevelopers themselves that already have a decent knowledge of it’s basics. But correct me if I’m wrong. :)

      • ddorian

        That’s like saying, “Why would I convert my PSD when a company can do it for me for free?”
        HINT HINT JEFREY not expression engine around here only open source

      • http://www.davidrojas.net David Rojas

        Totalle agree. Besides with something like Drupal or WordPress I’m always worried about security issues. You have to have it always updated, or else some bug could come up and get your client’s site hacked. If you have a lot of clients, keeping track of every system update is a problem, and then there’s the thing about plugins or modules breaking with new updates. That’s a mess that can be avoided if you build your own custom simple CMS. It still can be hacked, but it would be more difficult since it’s not complex and you have complete control over it, and is not vulnerable to script-kiddies attacks using common published bugs.

    • Ulrik

      For small customers and projects ive found it very much easier to just do a simple CMS with simple interface instead of implementing some system which requires som learning and has features not nessecary for a small time internet user.. Thats just my 2 cents

      • Web010

        I agree.

        But not always is needed to “reinvent the wheel”. There are a lot of things same for each project, and i don’t want to retype it every time, i just copy/paste and that’s it.
        Yesterday i was building a website for a customer and he needed CMS, so with few copy/paste and some new coding (which will probably be used on future projects) i made it in less then 10mins.

        So, no need to use Joomla or WordPress or whatever, just make a library of your own scripts for this purpose and that’s it.

        First time you will reinvent the wheel, it won’t be as good as some cms out there, but next time the wheel will not be reinvented again, you will just upgrade it…

    • http://copy112.com Copy112

      I needed a custom cms for a while ago, The client needed more control then joomla and drupal offered.

    • Atroxide

      If everyone always used the “Why do something that is already done” then there would be no way to improve what we already have.

      In the future some one will need to completely redesign the cms that are popular today, maybe in a different language or maybe to recode it to work with some advance technology in the future.

      There has to be someone to recreate the wheel every now or then to make it better.

      • eCaj

        our entire company is using a custom CMS developped from the ground up… It’s working just fine :)

    • cornelius

      i wish i could join but the network in Nigeria is frustration, so i cant watch videos, is there any way i can pay so that these materials can be sent? please i need help!

  • http://www.otheroom.com Barry Wood

    I just built a custom CMS for a client because there was an extensive database behind the scenes that was used to create pages that would have been impossible to render within the structure of a generic CMS. It was easier to code from scratch rather than to try to beat the CMS into submission.

    Aside from that I totally agree. When the information that needs to be presented can be presented easily by a CMS that’s the way to go. I’ve done custom Joomla sites for clients in those cases.

  • Paul du Long

    Finally a new PLUS tutorial … i was thinking i was PLUS member for nothing. Unfortanally it isnt quiet the subject i was hoping for. Nevertheless a good tutorial!

    Offtopic: How can i edit my avatar??

    • http://www.jeff-way.com Jeffrey Way

      Finally? We post a new tutorial each week – every Wednesday. We’ve yet to miss a week since the launch.

      • Hassan

        Jeff, I noticed everytime someone says FINALLY you always say that ! lol

      • Paul du Long

        I didn’t knew there was a system in it. However more PLUS tuts are always welcome (A). I also hope that there will be more (PLUS) tutorials that will cover more unique and difficulty topics. We just had a CRUD prepared statement what corresponds with this mysqlI.

        I was thinking of topics such as:
        – IRC Chat channel
        – Streaming (server)(webcam)(video) ?
        – Cool JQuery stuff combined with PHP / MYSQL and / or other sorts of cool stuff

      • Hassan

        One thing, When are you planning to create some new WordPress Series?

        -Sorry for the double post

      • Yosy

        There are a lot of plus tutorials but there is no good screencasts each week :( :(

      • Paul du Long

        Yes Jeffrey we’re missing the outstanding screencasts from you!

      • http://www.jeff-way.com Jeffrey Way

        @Paul – I’m running out of ideas. :)

        @Yosy – Not sure what you mean. This week’s screencast is excellent.

      • Paul du Long

        Why don’t you make a poll for PLUS members to see where they interested in. Or a “dumb-your-tutorial-request” somewhere, there are a lot of subjects to cover. I post some ideas in the reply down here ;)

        Smarty is a good idea, or a newsletter system. If you interested you can contact me :)

      • Scott

        I think a tutorial on paginating and pulling in new comments asychrounsuly would be great. Commenting like YouTube and Hulu have, where you click on another page of comments and they load up without a page refresh so not to disrupt the playback of the video you’re watching. I know many other sites do this as well.

    • http://www.jeff-way.com Jeffrey Way

      Heh, I do — because it always confuses me.

      • Yosy

        “@Yosy – Not sure what you mean. This week’s screencast is excellent.”

        When you started to do screencasts,you made them each week..
        week after week and now you made them once in two weeks ~

      • Ulrik

        Is it just me or did last weeks PLUS tutorial not make it to net.tutsplus as a post? The one with the Twitter search api??

  • Paul du Long

    Nevermind … now i see the link Gravatar *stupid*

  • Paul du Long

    More ideas for tutorials:
    – Emailing – PHP Mailer Class (contact me if you want a tut about this)
    – More about template systems (Smarty)

    • Yosy

      Yeah!!smarty video tutorial :D
      I think at nettuts+ the problem is what I have saw that the screencasts don’t use enough oop :( and publish tutorials for advanced developers.

      • Paul du Long

        I did, but they weren’t interested :l

    • http://sffarlenn.net Laneth Sffarlenn

      Paul,

      If ye can do or have a tut about the PHP Mailer Class and Emailing, why not contact the Tuts+ people and offer it to them as a Tut they can use?

      And thanks go to Sunil for this Tut – I’ve got my first web design gig on at the moment and was considering WordPress as the CMS for my client – now I have another option should he not like the WP site / options.

  • obey

    that sounds interesting :)
    might have to think to get a + account

  • http://www.l4u.dk/ Kasper

    Could have been interesting ;(

    Must… have.. plus!

  • Marc

    For the people thinking re-using a ready-made CMS and all that, Customers HATE .. i have lots of them.. HATE paying a couple thousand dollars for something that is free on the internet that you didn’t do much work for. The customers always love to get a custom thing, and then you don’t feel bad charging like 3-4 000$ for it.

    Learning PHP and MySQL that way is a great way. But people .. please… if you are a web professional and a customer wants a CMS .. please don’t use a free open source CMS because lots of times, people don’t learn them and make shitty modules or core changes that make it impossible to update later on.

    Thanks :P

    Nice semi article (i’m not on +)

    • http://www.twitter.com/kevinquillen Kevin Quillen

      “Customers HATE .. i have lots of them.. HATE paying a couple thousand dollars for something that is free on the internet that you didn’t do much work for.”

      That’s pretty flat out false. We let all our customers know we use the base of drupal to build up and customize their business needs. We fit program logic into drupal, which is why open source is so beneficial because we aren’t spending hours recoding/refining CRUD interfaces and reinventing features that already exist. That and we’re experienced developers so its not that hard.

      If you are selling customers a free CMS without adding anything into it, then they would have a reason to be upset. But from our perspective, we’re making it work for them.

      We had our own CFML CMS a few years ago, but it was impossible to maintain it and keep up with the rest of the world, so we switched to open source systems. There’s nothing wrong with this.

      “if you are a web professional and a customer wants a CMS .. please don’t use a free open source CMS because lots of times, people don’t learn them and make shitty modules or core changes that make it impossible to update later on.”

      Also just a flat out falsehood. Find a module, test it out. Results unexpected? Check issue queue or move on. Its not that difficult. We haven’t had a single issue finding/creating modules and updating core. And in our case, we’ve modified the core to perform extensively better than it will out of the box (CDN integration, super caching, load balancing, memcache, APC and the like).

      Its only impossible if that is the limit of your ability. No offense. Just tired of the FUD when it comes to open source systems.

  • josheat

    I have made many CMS systems for clients aged 25+ to 80.
    Not everyone can look at a massive joomla admin interface and know what to do, many people just give up there and look for another solution.

    Custom making a CMS is fun, you have full control over the website flow and after a few jobs you end up having a nice library of classes.
    Before you know it, a fully featured CMS that you have built yourself that you can start rolling out to each client with your branding on it! ;)

    • Palusko

      100% agree. Plus, in most cases, only some portions of the site need to be updated regularly, and it just is often easier for the customer to see a simple CMS interface for those sections, than to have a full-blown CMS for every detail of their page.

  • anomynous

    How about a tutorial about security on a production level since every tutorial infallibly gets the ol’ “it’s not production ready, use a framework instead” comments?

  • Moneyxl

    Thanks for this tutorial, I decided to join + last month and yes it has been a good investment, I mean $9 a month or whatever it is to be a plus member is basically less than what I pay for a gym session, the only thing is, I need to better organise my time to use actually learn some stuff that I’ve downloaded, great site, I’m happy I joined and would be joining for three months once my current monthly one’s up.

  • http://blog.designsector.org Sunil Agarwal

    Thank you all for your comments. I appreciate it :).

    For those wondering why a custom CMS, it’s because a custom CMS makes you the boss. The common CMS’s are too crazy and have unnecessary features like Joomla and Drupal (unless of course your website requires the tools it offers). And if you’re building a simple/regular website, sometimes even simple CMS’s like WordPress just won’t do it. With a custom CMS, you have the power to do whatever you want and add whatever functionality you need.

    For some it’s useful, for others it’s unnecessary. In the end, the point of the tutorial is to teach you the concept and how it’s made instead of whether or not it’s smart to make one.

  • Kyle

    Looking forward to diving into this. I had recently started working on my own CMS for my future wife to use and for my own knowledge. This should be helpful.

    Also, are there any soon to be tutorials on LDAP? I have so many ideas for small businesses that would run perfectly if I could just get LDAP to work properly.

  • http://vampa.org Alex Stomp

    WOW! I’ve been waiting for this…I’m probably going to offer CMS creation eventually for my web design business. Too bad it’s a plus tutorial…

    Can’t wait to read it once I join, if I join…but I probably will eventually :)

    • http://www.jeffadams.co.uk Jeff

      dude its like 9 dollars. In English pounds thats about £5. I can’t even get a McDonalds for that these days lol.

      • http://vampa.org Alex Stomp

        Yea… i know.. :) I’m actually probably going to get one soon, cause most of the really good tuts are plus now.

  • http://www.mamjed.com mamjed

    dude i dont see the screen cast. were is it, i downloaded the files.

    • http://myfacefriends.com Myfacefriends

      I’m afraid it’s a plus tutorial my friends you need to be registered i think for 9 dollars per month but that’s worth it!

      • http://www.mamjed.com mamjed

        i have the yearly subscription, downloaded the file and i dont see it

    • http://www.headydays.com/portfolio Jane

      Next to the tutorial in the tutsplus members area there’s a ‘view screencast’ link.

  • Jan

    Just thinking if it is good idea to create your own CMS and offer it to the clients from bussiness perspective.

    From my previous experiences I realise that having my own CMS it’s sometimes harder to offer to the client, because they want to have CMS which is well known for everyone, well documented, well supported (like Joomla! WordPress etc.), as your own CMS could be very difficult understand for someone who will take over client web service in the future.

    So what are your experiences? What do you prefer?

  • http://www.mindred.co.uk Steve

    Does this tutorial cover a membership system by any chance? Or is it just editing pages? Thanks

  • Paul du Long

    Not a member system, but a login system for 1 user ;)

  • http://www.zitrox.com Michael

    Great.. Exactly what i was looking for since a while!

    Using CMS like Joomla is ok, but for some clients just too powerful

  • http://www.exoph.com John

    Thanks so much! I’ve been waiting for a new PLUS tutorial that featured something different for once. It’s nice to see some different subjects that have nothing to do with PSD to HTML or PSD to WordPress. Glad we’re switching it up some.

  • Web010

    Anybody wants me to send him money to moneybookers and he purchase a plus membership for me?

  • http://www.xtensives.com Hasanga

    @Jeffrey:
    what? you are running out of ideas?

    I suggest you to take a look at http://psdtuts.uservoice.com/pages/nettuts_tutorial_suggestions

    hey Sunil! love this kinda tuts man! are you planing to have any thing in future under this topic?
    If so Please also consider about implementing a plugin API and modular.

    Cheeerrss!

  • http://www.jeffadams.co.uk Jeff

    is anyone else having trouble viewing the screencast. I get to a certain point and it just kinda freezes? Wanted to know if it was just me.

    I tried downloading the FLV file too with no joy. Gutted lol.

    • http://www.jeffadams.co.uk Jeff

      nevermind found it works in IE for me lol

  • MrShish

    Here in Sweden, EPI Server seems to be the shizzle when it comes to CMSes. Do anyone of you know how it’s compared to EE, Drupal or any other Open Source CMSses?

  • masterpsk

    Is anyone else having problems with membership? i joined this morning and Paypal already took my money, still i have no confirmation email from Tutsplus and I cant acces Plus content.

  • Jez

    Just signed up for tutsplus as i was looking for a simple, non bloated CMS :)

    Watched the tutorial, then as I’m not the greatest coder, uploaded the files to my server, created the database and uploaded the .sql, changed the connection.php file to details used for my database….

    but it does not work. just getting the following html output in the browser, it aint conecting to the database….any ideas ??

    beta – a free web template by spyka webmaster

    beta
    spyka.net – you know you want to

  • Jez

    ok reinstalled everything and its working fine :) so ignore my last comment

  • http://www.dsaportfolio.com.br Diego SA

    Ahhhhhh! Damn! There’s something I really need in this tutorial. AAAAHHHH! Don’t have plus.

    • http://www.jeffadams.co.uk Jeff

      It’s $9.99 a month, even if you subscribed for a month you’d get access to this, some excellent Shopping Cart tutorials and some other neat tutorials and if Photoshop is your bag there re LOADS in that area.

      $9.99, thats it.

  • http://www.emagenstudios.com Jesse Esquibel

    It’s interesting this tut was posted. A client of mine just asked for a custom CMS for their site and I need a refresher course.

    I’m glad I joined.

  • http://www.massbase.com Massbase

    thank you for this, i really need this, i might apply for a months worth of plus tutorials.

  • Simon

    Well, why not vote for this suggestion:

    Tutorial about the template system called Smarty and its advanced features. It’s really difficult to find some interesting indeep tutorials about this engine so this would be unique !
    - Setup
    - How to use
    - features (loops, functions, etc.)
    - Good and bad uses
    - etc.
    Thanks !

    url: http://psdtuts.uservoice.com/pages/2997-nettuts-tutorial-suggestions/suggestions/225766-advanced-use-of-template-systems-smarty-
    I would be ready to pay for such tutorials !
    So let’s vote ;)

  • http://www.allisclear.com Stefan Ashwell

    Shame I don’t have plus, does anyone know of a good alternative to TinyMCE though? TinyMCE is great, just a shame its soo big!

    • http://www.twitter.com/kevinquillen Kevin Quillen

      TinyMCE is like one of the smaller text editors. You can use the compressed js version or Tiny TinyMce.

      FCK is also popular, but also really bloated.

      There is also WYMEditor: http://www.wymeditor.org/

  • http://www.google.com vinod

    Hi Tutsplus,

    I would like to join in tutsplus on an yearly subscription basis, unfortunatelly I don’t have credit card or paypal account, Could you please let me know is there any payment options available apart from those.

  • RNR

    Thanks for the TUT. You’re very easy to understand and follow – much appreciated.

    I may be missing something, but is there a way to fast forward and rewind while watching the TUT PLUS screencasts? I like to review things a number of times while watching screencasts.

  • http://www.bestwebcents.com Rock Your Web

    Nice article. Good job.

  • Art

    Ok I have a problem. I am trying to make a little script to add pages without having to go into the sql database. And i have a script that works but has problems. How would i combine the following sql statements into one?

    $sql = “INSERT INTO page (id, name, content) VALUES (‘$id’, ‘$name’, ‘$content’);”;
    $sql = “INSERT INTO nav (id, name, url, title) VALUES (‘$id’, ‘$name’, ‘$url’, ‘$title’);”;

    • Art

      Never mind I figured it out through the magic of trial and error.

  • Dave

    Very nice!!! I think a tutorial about portfolio cms(portfolio manager) is also a good idea…

  • http://www.designbariloche.com Jez

    Uploading Images via Tiny MCE

    Spent hours trying different options and then found one that was almost straightforward:

    http://www.lunarvis.com/products/tinymcefilebrowserwithupload.php

  • http://www.downwithdesign.com Gareth Hardy

    I’ve been looking for something like this for some time, thank you so much :)

    Hmmm now to have a go…

  • http://www.indiawebmediapro.com/ Aliester

    Hey nice article it is.you are easy to understand this,It gives a new idea to me for custom cms.

  • http://slackrmedia.com Keenan Payne

    Well you guys got me on this one. Time to sign up for Tuts Plus.

  • Nate

    Wow. With all these Tuts+ tutorials I’ve learned some major web development. If I’m building WordPress themes, jQuery Plugins and Custom CMSes at 13, I will probably be a web master when I’m an adult.

  • Mr Twiste

    Are the videos downloadlable ? If yes, what is the size of this one ?

  • Mr Twister

    Are the videos downloadable?

  • http://www.altograu.eu/portfolio Sérgio Soares

    I have a problem when i’m trying to update the pages section:

    Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\wamp\www\website\update.php on line 10

    anyone can help me? i tried everything and nothing

    Thanks

    • Alex

      Yeah I’ve been having the same issue.

  • Mr Twister

    Are the videos downloadable or NOT >

  • Mr Twister

    And wbat is the size of this one ?

  • aks

    cannot this tutorial be accessed without joining tutplus lol?

  • Manuel Corazzari

    im having a begginers problem to see the website and i get this message >>>

    The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.