Skip to content

mitindas/php-content-management-system

Repository files navigation

PHP Blog Website

A complete blog website with user registration, authentication for blog management. Built with PHP, MySQL, HTML, CSS, and JavaScript.

Features

  • 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

Setup Instructions for XAMPP

Prerequisites

  • XAMPP installed on your system

Installation Steps

  1. Copy Project Files

    • Copy the php-blog-website folder to your XAMPP htdocs directory
    • Path: C:\xampp\htdocs\ (Windows) or /Applications/XAMPP/htdocs/ (Mac)
  2. Start XAMPP Services

    • Open XAMPP Control Panel
    • Start Apache server
    • Start MySQL server
  3. Create Database

    • Open your browser and go to: http://localhost/phpmyadmin
    • Click on "Import" tab
    • Click "Choose File" and select the database.sql file 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.sql file
    • Click "Go"
  4. 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');
  5. Set Permissions

    • Ensure the uploads folder has write permissions
    • Windows: Right-click folder → Properties → Security → Edit → Add write permissions
    • Mac/Linux: chmod 755 uploads
  6. Access the Website

    • Open your browser
    • Go to: http://localhost/php-blog-website/

Project Structure

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

Database Schema

Users Table

  • id - Primary key
  • username - Unique username
  • email - Unique email address
  • password - Hashed password
  • full_name - User's full name
  • bio - User biography (optional)
  • created_at - Registration timestamp

Blogs Table

  • id - Primary key
  • user_id - Foreign key to users table
  • title - Blog title
  • content - Blog content
  • image - Path to featured image
  • status - draft or published
  • created_at - Creation timestamp
  • updated_at - Last update timestamp

Usage Guide

For Users/Authors:

  1. Register an Account

    • Go to the registration page
    • Fill in username, email, full name, and password
    • Optionally add a bio
    • Click "Register"
  2. Login

    • Use your username or email
    • Enter your password
    • Click "Login"
  3. 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"
  4. Edit a Blog

    • Go to your Dashboard
    • Click "Edit" on any blog
    • Make your changes
    • Click "Update Blog"
  5. Delete a Blog

    • Go to your Dashboard
    • Click "Delete" on any blog
    • Confirm deletion

For Visitors:

  1. View Blogs
    • Visit the homepage to see all published blogs
    • Click "Read More" to view full blog content

Security Features

  • 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)

Troubleshooting

Common Issues:

  1. "Connection failed" error

    • Make sure MySQL is running in XAMPP
    • Verify database credentials in includes/config.php
    • Ensure database blog_website exists
  2. Images not uploading

    • Check that uploads folder exists
    • Verify folder has write permissions
    • Ensure image file size is under 5MB
  3. "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/
  4. Session errors

    • Clear browser cookies and cache
    • Restart Apache server in XAMPP

Technologies Used

  • Backend: PHP
  • Database: MySQL
  • Frontend: HTML, CSS, JavaScript
  • Server: Apache Server (via XAMPP)

License

This project is open-source and available for educational purposes.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published