A lightweight PHP blog system built without frameworks. Ideal for beginners who want to learn the full stack (PHP + MySQL + Bootstrap) while practicing CRUD, session handling, image upload, and basic security.
- 🧑💼 Admin authentication (session-based login)
- 📝 Create, read, update, and delete blog posts
- 🖼️ Image upload support with preview
- ✍️ Rich text editor with TinyMCE
- 🕓 "Time ago" formatted timestamps (
Posted 5 mins ago) - 🔍 Admin search, date filters (month/year), and pagination
- 🧼 Input validation and flash messages
- ⚙️ Built with vanilla PHP, PDO (MySQL), and Bootstrap
/simple_blog/
│
├── admin/ # Admin-only logic (login/logout)
│ ├── auth.php # Login/auth protection middleware
│ └── login.php # Admin login page
│
├── classes/
│ └── Blog.php # Main blog logic (DB operations, helpers)
│
├── helpers/
│ └── flash.php # Flash message system
│
├── uploads/ # Uploaded post images
│
├── blog.sql # Database schema
├── create.php # Create new post
├── edit.php # Edit a post
├── delete.php # Delete post by ID
├── index.php # List all posts (public)
├── post.php # View a single post
├── logout.php # Destroy session and redirect
├── db.php # PDO DB connection
└── README.md # You're reading thisgit clone https://github.com/yourusername/simple-php-blog.git
cd simple-php-blog- Open phpMyAdmin or your MySQL client.
- Create a new database (e.g.
simple_blog) - Import the
blog.sqlfile included in the root directory.
Update your db.php file with your database credentials:
$pdo = new PDO("mysql:host=localhost;dbname=simple_blog", "root", "");php -S localhost:8000Then open your browser and visit: http://localhost:8000
To access the admin dashboard:
- URL:
http://localhost:8000/admin/login.php - Default credentials:
Username: admin
Password: 1234
admin/login.php. You can update them or add a proper login system later.
- Upload all files to
public_html/or a subfolder. - Import
blog.sqlusing phpMyAdmin. - Edit
db.phpwith your host's credentials.
- Copy the project to
htdocs/ - Start Apache and MySQL from XAMPP
- Open http://localhost/simple-php-blog
| Home Page | Rich Text Editor |
|---|---|
![]() |
![]() |
| Admin View | Post View |
|---|---|
![]() |
![]() |
| Post List |
|---|
![]() |
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is open source and available under the MIT License.
🧠 Built by learners, for learners. Happy coding!




