A complete blog website with user registration, authentication for blog management. Built with PHP, MySQL, HTML, CSS, and JavaScript.
-
User Registration & Authentication
- Secure password hashing
- User login/logout functionality
- Session management
-
Blog Management (CRUD Operations)
- Create new blog posts
- Edit existing blogs
- Delete blogs
- View all blogs
-
User Roles
- Authors can manage their own blogs
- Public users can view published blogs
- Draft and published status for blogs
- XAMPP installed on your system
-
Copy Project Files
- Copy the
php-blog-websitefolder to your XAMPPhtdocsdirectory - Path:
C:\xampp\htdocs\(Windows) or/Applications/XAMPP/htdocs/(Mac)
- Copy the
-
Start XAMPP Services
- Open XAMPP Control Panel
- Start Apache server
- Start MySQL server
-
Create Database
- Open your browser and go to:
http://localhost/phpmyadmin - Click on "Import" tab
- Click "Choose File" and select the
database.sqlfile from the project folder - Click "Go" to import the database
OR manually create:
- Click "New" in phpMyAdmin
- Create database named:
blog_website - Go to SQL tab and paste the contents of
database.sqlfile - Click "Go"
- Open your browser and go to:
-
Configure Database Connection (Optional - already configured for XAMPP defaults)
- Open
includes/config.php - Verify these settings match your XAMPP MySQL configuration:
define('DB_HOST', 'localhost'); define('DB_USER', 'root'); define('DB_PASS', ''); // Empty for default XAMPP define('DB_NAME', 'blog_website');
- Open
-
Set Permissions
- Ensure the
uploadsfolder has write permissions - Windows: Right-click folder → Properties → Security → Edit → Add write permissions
- Mac/Linux:
chmod 755 uploads
- Ensure the
-
Access the Website
- Open your browser
- Go to:
http://localhost/php-blog-website/
php-blog-website/
│
├── includes/
│ ├── config.php # Database configuration
│ └── auth.php # Authentication functions
│
├── css/
│ └── style.css # Stylesheet
│
├── js/
│ └── script.js # JavaScript functionality
│
├── uploads/ # Directory for uploaded images
│
├── database.sql # Database schema
├── index.php # Homepage (view all published blogs)
├── register.php # User registration
├── login.php # User login
├── logout.php # User logout
├── dashboard.php # User dashboard (view own blogs)
├── create_blog.php # Create new blog
├── edit_blog.php # Edit existing blog
├── delete_blog.php # Delete blog
├── view_blog.php # View single blog
└── README.md # This file
id- Primary keyusername- Unique usernameemail- Unique email addresspassword- Hashed passwordfull_name- User's full namebio- User biography (optional)created_at- Registration timestamp
id- Primary keyuser_id- Foreign key to users tabletitle- Blog titlecontent- Blog contentimage- Path to featured imagestatus- draft or publishedcreated_at- Creation timestampupdated_at- Last update timestamp
-
Register an Account
- Go to the registration page
- Fill in username, email, full name, and password
- Optionally add a bio
- Click "Register"
-
Login
- Use your username or email
- Enter your password
- Click "Login"
-
Create a Blog
- After login, click "New Blog" or go to Dashboard
- Fill in blog title and content
- Optionally upload a featured image
- Choose status (Draft or Published)
- Click "Create Blog"
-
Edit a Blog
- Go to your Dashboard
- Click "Edit" on any blog
- Make your changes
- Click "Update Blog"
-
Delete a Blog
- Go to your Dashboard
- Click "Delete" on any blog
- Confirm deletion
- View Blogs
- Visit the homepage to see all published blogs
- Click "Read More" to view full blog content
- Password hashing using PHP's
password_hash()function - SQL injection prevention using prepared statements
- XSS protection with
htmlspecialchars() - Session management for authentication
- File upload validation (type and size)
- User authorization checks (users can only edit/delete their own blogs)
-
"Connection failed" error
- Make sure MySQL is running in XAMPP
- Verify database credentials in
includes/config.php - Ensure database
blog_websiteexists
-
Images not uploading
- Check that
uploadsfolder exists - Verify folder has write permissions
- Ensure image file size is under 5MB
- Check that
-
"Page not found" error
- Ensure Apache is running in XAMPP
- Verify the project folder is in
htdocs - Check the URL:
http://localhost/php-blog-website/
-
Session errors
- Clear browser cookies and cache
- Restart Apache server in XAMPP
- Backend: PHP
- Database: MySQL
- Frontend: HTML, CSS, JavaScript
- Server: Apache Server (via XAMPP)
This project is open-source and available for educational purposes.