Blog 4 min read

How I Built a Custom Admin Panel in PHP for Full Content Control and you can too

By Copernicus August 12, 2025

The next logical step in my learning journey was to build a private, password protected admin panel. I wanted a good dashboard where I could see all my content at a glance and have full control over it. This post is the story of how I built the core features of that dashboard using PHP.

The Main Dashboard: Displaying All Posts

The very first thing I needed was a simple list of all my articles. I wanted a clean table that showed me the title, the category, and when it was created.

The logic behind this is surprisingly straightforward. My manage_posts.php ( you can set your own name ) script does three simple things:

  1. It connects to the MySQL database.

  2. It runs a single SQL query: SELECT id, title, category, created_at FROM posts ORDER BY created_at DESC. This command fetches the key details for every post and sorts them so the newest ones are always at the top.

  3. It then uses a basic foreach loop in PHP to go through each post it received from the database and print it as a new row in an HTML table.

Just like that, with one database query and one loop, I had a dynamic and organized view of all my content.

The 'Delete' Functionality: Making the Dashboard Interactive

Seeing the posts was great, but I needed to be able to interact with them. The first action I added was a "delete" button. This was my first real taste of making the admin panel do something tangible.

Here’s how I figured out the process:

Next to each post in my dashboard table, the "delete" button is actually a link. This link is special because it includes the post's unique id in the URL. It looks something like this: delete_post.php?id=17.

When I click that link, a separate script, delete_post.php, takes over.

This script's only job is to grab the id from the URL (in this case, 17), connect to the database, and run a very specific command. I learned to use a prepared statement to do this safely, which looks like this: DELETE FROM posts WHERE id = ?.

The script plugs the id into that question mark and tells the database to remove only that specific row. Using the unique id is so important because it guarantees that I will only ever delete the exact post I intended to, and nothing else. It’s precise and safe.

The 'Create' and 'Edit' Forms: The Heart of the CMS

So of course, a dashboard isn't just for viewing and deleting. The most important part of a Content Management System is, well, managing the content! My dashboard also has prominent links that take me to two other pages: create_post.php and edit_post.php.

These two forms are the true heart of the CMS. They are where I can write new articles from scratch or go back and update existing ones.

I plan on covering exactly how I built the "edit" form in my next blog post. It involves some interesting logic for fetching existing data and updating it in the database, and I think it deserves its own detailed walkthrough.

Conclusion

And that's the core of my admin panel. It was a huge "heh" moment for me when I realized that a powerful and functional dashboard wasn't some magical, complicated thing. It's really just built on a simple PHP loop to display data, and a few basic SQL commands to create, edit, and delete that data. With these building blocks, I was able to create a tool that gives me full control over my website's content.

In the next article of this series, we'll dive deep into the edit_post.php form ( if i am free ) . We'll look at how to pull a post's data from the database into a form, and how to safely update that record after making changes. Thanks for reading.

you might also like...