A complete Content Management System built using PHP, MySQL, HTML, CSS, JavaScript, jQuery, and Bootstrap.
The project contains a public-facing news and blog website along with a separate admin dashboard. Administrators can manage posts, categories, comments, users, and profile information through CRUD operations.
This project was developed to understand how a complete dynamic website works with a PHP backend and a MySQL database.
The public website allows visitors to browse published posts, search content, view posts by category or author, register, log in, and submit comments.
The admin dashboard provides content-management functionality such as creating, reading, updating, and deleting posts, categories, users, and comments.
- View published posts
- Read complete post details
- Browse posts by category
- Browse posts by author
- Search posts
- Navigate posts using pagination
- View post publication date
- View post images and content
- User registration
- User login and logout
- Submit comments on posts
- Display approved comments
- Track individual post views
- Responsive Bootstrap navigation and layout
- Secure session-based admin area
- Dashboard with total record counts
- Display total posts
- Display total comments
- Display total users
- Display total categories
- Visual statistics using Google Charts
- View published and draft post counts
- View approved and unapproved comment counts
- View admin and subscriber user counts
- Online-user activity counter
- Add new posts
- View all posts
- Edit existing posts
- Delete posts
- Upload post images
- Assign categories to posts
- Add post title
- Add post author
- Add post tags
- Add rich-text post content
- Set post status as published or draft
- Perform bulk operations on selected posts
- Track post views and comment counts
- Add new categories
- View all categories
- Edit categories
- Delete categories
- View all submitted comments
- Approve comments
- Unapprove comments
- Delete comments
- Associate comments with individual posts
- Display only approved comments on the public website
- Add new users
- View all users
- Edit user information
- Delete users
- Assign admin or subscriber roles
- Promote or demote users
- Register new subscriber accounts
- Update profile information
- HTML5
- CSS3
- JavaScript
- jQuery
- Bootstrap
- Font Awesome
- Summernote Rich Text Editor
- Google Charts
- PHP
- MySQL
- MySQLi
- Apache Server
- XAMPP, WAMP, or LAMP
- phpMyAdmin
This project helped me practise:
- PHP syntax and server-side rendering
- PHP includes
- Form handling
- GET and POST requests
- Sessions
- Authentication
- Role-based access
- Password hashing
- Password verification
- File uploads
- Redirects using headers
- Reusable PHP functions
- Conditional rendering
- Dynamic page routing using query parameters
- Pagination
- Working with arrays
- Error handling
- Database connections
- MySQL queries
- CRUD operations
- Aggregate database counts
- Search functionality
- Comment moderation
The project performs all four main CRUD operations.
- Create posts
- Create categories
- Create users
- Create comments
- Register new accounts
- Display posts
- Display categories
- Display users
- Display comments
- Display dashboard statistics
- Search and filter content
- Edit posts
- Update post status
- Edit categories
- Update users
- Update profiles
- Approve or unapprove comments
- Delete posts
- Delete categories
- Delete users
- Delete comments
cms-main/
│
├── admin/
│ ├── css/
│ ├── font-awesome/
│ ├── includes/
│ │ ├── add_post.php
│ │ ├── add_user.php
│ │ ├── admin_footer.php
│ │ ├── admin_header.php
│ │ ├── admin_navbar.php
│ │ ├── edit_post.php
│ │ ├── edit_user.php
│ │ ├── functions.php
│ │ ├── update_cat.php
│ │ ├── user_edit_profile.php
│ │ ├── view_all_comments.php
│ │ ├── view_all_post.php
│ │ └── view_all_users.php
│ │
│ ├── js/
│ ├── admin_comments.php
│ ├── admin_post.php
│ ├── admin_users.php
│ ├── categories.php
│ ├── index.php
│ └── profile.php
│
├── css/
│ ├── blog-home.css
│ ├── blog-post.css
│ ├── bootstrap.css
│ ├── bootstrap.min.css
│ └── style.css
│
├── fonts/
├── images/
│
├── includes/
│ ├── db.php
│ ├── footer.php
│ ├── header.php
│ ├── login.php
│ ├── logout.php
│ ├── navbar.php
│ ├── sidebar.php
│ └── sidewall.php
│
├── js/
│ ├── bootstrap.js
│ ├── bootstrap.min.js
│ └── jquery.js
│
├── author.php
├── category.php
├── comments.php
├── index.php
├── post.php
├── registration.php
├── search.php
└── README.md
- Published posts are fetched from the MySQL database.
- The posts are displayed on the home page.
- Visitors can open a complete post.
- Each post visit increments its view count.
- Visitors can filter posts by category or author.
- Visitors can search for posts.
- Users can register and log in.
- Visitors can submit comments.
- Submitted comments remain unapproved until reviewed by an administrator.
- Approved comments become visible on the public post page.
- The administrator logs into the system.
- PHP creates a session for the authenticated user.
- The administrator is redirected to the dashboard.
- Dashboard cards display totals for posts, comments, users, and categories.
- Google Charts display active and inactive content statistics.
- The administrator can manage all website content through CRUD operations.
The system supports two user roles:
Administrators can access the dashboard and manage:
- Posts
- Categories
- Comments
- Users
- Profile information
Subscribers can register and log in to the public website.
PHP sessions are used to preserve authenticated user information.
Passwords are stored using PHP's password-hashing functionality:
password_hash($password, PASSWORD_DEFAULT);During login, passwords are verified using:
password_verify($enteredPassword, $storedPassword);The home page divides posts into multiple pages.
The total number of pages is calculated using the total post count and the number of posts displayed per page.
$post_count = ceil($post_count / 3);Each page displays a limited number of posts using a MySQL LIMIT query.
Comments submitted from the public website are initially stored with an unapproved status.
unapproved
An administrator can approve the comment from the dashboard.
Only comments with the following status are displayed publicly:
approved
This creates a basic moderation workflow for user-generated content.
The admin dashboard includes summary cards for:
- Posts
- Comments
- Users
- Categories
It also uses Google Charts to compare:
- Total records
- Active records
- Inactive records
Examples include:
- Published and draft posts
- Approved and unapproved comments
- Admin and subscriber users
Before running the project, install one of the following local server environments:
- XAMPP
- WAMP
- LAMP
- MAMP
The environment should include:
- Apache
- PHP
- MySQL
- phpMyAdmin
git clone https://github.com/your-username/php-cms.gitFor XAMPP, move the project folder into:
C:/xampp/htdocs/
Example:
C:/xampp/htdocs/cms-main/
Open the XAMPP Control Panel and start:
- Apache
- MySQL
Open phpMyAdmin:
http://localhost/phpmyadmin
Create a database named:
cms
The database connection is located in:
includes/db.php
Default configuration:
$db['hostname'] = "localhost";
$db['username'] = "root";
$db['password'] = "";
$db['dbname'] = "cms";Change these values according to your local MySQL setup.
The application expects the following tables:
posts
categories
users
comments
user_online
Make sure the database schema contains the columns used by the application.
The current repository does not include a database SQL export. The database must be recreated or imported separately before running the complete application.
Open:
http://localhost/cms-main/
Admin dashboard:
http://localhost/cms-main/admin/
Stores:
- Post ID
- Category ID
- Title
- Author
- Date
- Image
- Content
- Tags
- Status
- Comment count
- View count
Stores:
- Category ID
- Category title
Stores:
- User ID
- First name
- Last name
- Username
- Password
- Role
Stores:
- Comment ID
- Related post ID
- Author
- Content
- Status
- Date
Stores:
- Session ID
- Activity time
The project includes basic security practices such as:
- Password hashing
- Password verification
- Session-based authentication
- Role-based redirection
- Input escaping using MySQLi
- Restricted admin-page access
This project was developed as a learning project. Before using it in production, additional security improvements should be implemented.
- Use prepared statements for every database query
- Add CSRF protection
- Validate and sanitize all form inputs
- Escape output before displaying it
- Validate uploaded file type and size
- Generate unique uploaded filenames
- Restrict direct access to admin pages
- Add stronger role checks for admin-only actions
- Remove database credentials from source code
- Store credentials using environment variables
- Add duplicate username and email validation
- Add password-strength validation
- Add secure session-cookie settings
- Add login rate limiting
- Add confirmation before delete operations
- Use POST requests instead of GET requests for destructive actions
While building this project, I learned:
- How to build a complete PHP and MySQL web application
- How frontend pages communicate with a backend
- How to connect PHP with a MySQL database
- How to perform CRUD operations
- How to build a reusable PHP project structure
- How to create a public website and separate admin panel
- How to manage authenticated users using sessions
- How to implement admin and subscriber roles
- How to upload and display images
- How to create a comment-approval workflow
- How to implement pagination and search
- How to display live database statistics
- How to use Bootstrap for responsive layouts
- How to organise a larger project using PHP includes
- Add a database SQL export file
- Rewrite queries using prepared statements
- Add CSRF tokens
- Improve admin authorization
- Add password-reset functionality
- Add email verification
- Add slug-based post URLs
- Add a rich-text image-upload feature
- Add post scheduling
- Add reusable form-validation messages
- Add activity logs
- Add media-library management
- Add responsive UI improvements
- Add REST API endpoints
- Rebuild the frontend using React
- Use Laravel for a modern backend version
Yash Guram
Computer Engineering graduate interested in frontend, backend, and full-stack web development.
Completed full-stack learning project built with PHP, MySQL, JavaScript, jQuery, and Bootstrap.