A modern, full-featured blog platform built with HTML, CSS, JavaScript, PHP, and MySQL. Create, share, and interact with blog posts in a beautiful dark-themed interface.
- User Authentication: Secure registration, login, and logout with session management
- Blog Management: Create, read, update, and delete blog posts
- Rich Text Editor: WYSIWYG editor with Quill.js for formatting content
- Image Upload: Upload and embed images in blog posts
- Comments System: Add comments to blog posts
- Like System: Like and unlike posts with real-time counts
- User Profiles: Custom avatars and user information
- Modern UI: Beautiful dark theme with gradient accents and smooth animations
- Responsive Design: Works seamlessly on desktop, tablet, and mobile devices
- Card Grid Layout: Posts displayed in an attractive grid format
- Frontend: HTML5, CSS3, JavaScript (Vanilla)
- Backend: PHP 7.4+
- Database: MySQL/MariaDB
- Libraries:
- Quill.js - Rich text editor
- Marked.js - Markdown parsing
- DOMPurify - XSS protection
- PHP 7.4 or higher
- MySQL/MariaDB 5.7 or higher
- Web server (Apache/Nginx) or PHP built-in server
- PHP extensions:
mysqli,openssl,json,session
Download the project files to your local machine or web server.
-
Start MySQL (via XAMPP, WAMP, MAMP, or standalone)
-
Create the Database:
- Open phpMyAdmin (usually at
http://localhost/phpmyadmin) - Or use MySQL command line:
mysql -u root -p
- Open phpMyAdmin (usually at
-
Import the Schema:
- In phpMyAdmin: Click "Import" β Select
db.sqlβ Click "Go" - Or via command line:
mysql -u root -p < db.sql
- In phpMyAdmin: Click "Import" β Select
Edit config.php and update the database credentials if needed:
$DB_HOST = 'localhost'; // Database host
$DB_NAME = 'blog_app'; // Database name
$DB_USER = 'root'; // MySQL username
$DB_PASS = ''; // MySQL password (empty for XAMPP default)
$DB_PORT = '3306'; // MySQL portEnsure these directories exist and are writable:
assets/uploads/- For blog post imagesassets/avatars/- For user avatars
Option A: Using the Batch File (Windows)
- Double-click
start-server.bat - Server will start at
http://localhost:8000
Option B: Using Command Line
php -S localhost:8000 -t .Option C: Using XAMPP/WAMP
- Place files in
htdocsorwwwdirectory - Access via
http://localhost/Blog/index.html
Open your browser and navigate to:
http://localhost:8000/index.html
Blog/
βββ api/ # PHP API endpoints
β βββ auth_login.php # User login
β βββ auth_register.php # User registration
β βββ auth_logout.php # User logout
β βββ me.php # Get current user
β βββ blog_create.php # Create blog post
β βββ blog_update.php # Update blog post
β βββ blog_delete.php # Delete blog post
β βββ blog_list.php # List all posts
β βββ blog_get.php # Get single post
β βββ comment_add.php # Add comment
β βββ comment_list.php # List comments
β βββ like_toggle.php # Toggle like
β βββ like_count.php # Get like count
β βββ avatar_upload.php # Upload avatar
β βββ upload_image.php # Upload blog images
βββ assets/
β βββ styles.css # Main stylesheet
β βββ app.js # Frontend JavaScript
β βββ favicon.svg # Site favicon
β βββ uploads/ # Blog post images
β βββ avatars/ # User avatars
βββ index.html # Home page (blog list)
βββ blog.html # Single post view
βββ editor.html # Post editor
βββ login.html # Login page
βββ register.html # Registration page
βββ config.php # Database configuration
βββ db.sql # Database schema
βββ start-server.bat # Windows server starter
βββ README.md # This file
-
Register an Account:
- Click "Register" in the navigation
- Fill in username, email, and password
- Click "Create Account"
-
Login:
- Use your email and password to login
-
Create Your First Post:
- Click "New Post" in the navigation
- Enter a title
- Write your content using the rich text editor
- Upload images if needed
- Click "Save" to publish
- Creating Posts: Use the rich text editor with formatting options, headers, lists, links, and code blocks
- Uploading Images: Click "Upload Image(s)" button, select images, then insert them into your post
- Editing Posts: Click "Edit" on your own posts
- Deleting Posts: Click "Delete" on your own posts
- Liking Posts: Click the heart icon to like/unlike posts
- Commenting: Scroll to the comments section and add your thoughts
- Changing Avatar: Click on your avatar in the navigation to upload a new one
- Logout: Click your username β "Logout" from the dropdown menu
Edit config.php to configure your database connection.
Errors are logged to php-errors.log in the project root. To see errors on screen during development, edit config.php:
ini_set('display_errors', 1); // Change from 0 to 1If you need to upload larger images, edit php.ini:
upload_max_filesize = 10M
post_max_size = 10M- Verify MySQL is running
- Check database credentials in
config.php - Ensure
blog_appdatabase exists (importdb.sql)
- Check
php-errors.logfor detailed errors - Verify PHP extensions are enabled (
mysqli,openssl) - Check file permissions on upload directories
- Ensure
assets/uploads/directory exists and is writable - Check PHP upload limits in
php.ini - Verify directory permissions (755 or 777)
- Change port in
start-server.bat:php -S localhost:8080 -t . - Access at
http://localhost:8080/index.html
- Install XAMPP, WAMP, or MAMP
- Or add PHP to your system PATH
- Or use full path:
C:\xampp\php\php.exe -S localhost:8000 -t .
- Passwords are hashed using PHP's
password_hash()function - All user inputs are sanitized and validated
- SQL injection protection via prepared statements
- XSS protection with DOMPurify
- Session-based authentication
- CSRF protection recommended for production
- Use HTTPS in production environments
POST /api/auth_register.php- Register new userPOST /api/auth_login.php- Login userPOST /api/auth_logout.php- Logout userGET /api/me.php- Get current user info
GET /api/blog_list.php- List all postsGET /api/blog_get.php?id={id}- Get single postPOST /api/blog_create.php- Create postPOST /api/blog_update.php- Update postPOST /api/blog_delete.php- Delete post
GET /api/comment_list.php?post_id={id}- List commentsPOST /api/comment_add.php- Add comment
GET /api/like_count.php?post_id={id}- Get like countPOST /api/like_toggle.php- Toggle like
POST /api/avatar_upload.php- Upload user avatarPOST /api/upload_image.php- Upload blog image
- Create a PHP hosting account and MySQL database
- Upload all files via FTP or File Manager
- Update
config.phpwith hosting provider's database credentials - Import
db.sqlvia phpMyAdmin - Set proper file permissions (755 for directories, 644 for files)
- Access your site at the provided domain
- Change
display_errorsto0inconfig.php - Use HTTPS (SSL certificate)
- Update database credentials
- Set secure session cookie parameters
- Configure proper file permissions
- Set up regular database backups
- Enable error logging
- Review and test all functionality
This project is open source and available for personal and commercial use.
Feel free to fork, modify, and use this project for your own needs. Contributions and improvements are welcome!
For issues or questions:
- Check the troubleshooting section
- Review error logs (
php-errors.log) - Verify database and PHP configuration
- Test with the diagnostic script:
http://localhost:8000/test-connection.php
Blog Hub - Share your thoughts, connect with readers, and build your community! π