Welcome to My-Blog, a PHP-based blog platform where users can create, manage, and explore blog posts with ease. With a simple and intuitive interface, anyone can share their thoughts and ideas with the world! 🌍
- 🔐 User Authentication: Sign up, log in, and log out with secure authentication.
- ✏️ Blog Management: Create, edit, and delete blog posts seamlessly.
- 🖼️ Image Upload: Upload images for your blog posts (supports JPG, PNG, GIF formats).
- 🏷️ Categories & Tags: Add categories and tags to organize your blog posts.
- 📱 Responsive Design: The design adapts beautifully to different devices.
- 🔒 Security First: We prioritize your security with input sanitization, hashed passwords, and error handling.
-
Clone the Repository:
git clone https://github.com/ahmedalsanadi/my-blog.git cd my-blog
-
Install Required PHP Extensions:
Ensure PHP environment has thePDO
extension for MySQL. -
Configure Database:
Modify thedb.php
file inapp/config/
with your database details:const DB_HOST = 'localhost'; const DB_USER = 'root'; const DB_PASSWORD = ''; const DB_NAME = 'blog';
-
Import Database:
Run the following command to import the database schema and sample data:mysql -u root -p blog < ./Database/blog.sql
-
Run the App:
Open your browser and navigate tohttp://localhost/my-blog
.
- The database schema is located in the
./Database/blog.sql
file. - Import the schema with:
SOURCE ./Database/blog.sql;
my-blog/
├── app/
│ ├── config/ # Configuration files
│ ├── controllers/ # Handles logic for blog and user
│ ├── models/ # Models interacting with the database
│ └── router/ # Route handler
├── pages/ # Static pages
├── views/ # HTML templates
├── uploads/ # Directory for blog images
├── Database/ # Database schema
└── index.php # Main entry point
Here are the key routes of the application:
/home
: View all blogs on the homepage./about
: Learn more about this blog platform./contact
: Contact form for reaching out./sign-in
: Log in to your account./sign-up
: Register a new account./blog/create
: Create a new blog post (requires login)./blog/edit?id={id}
: Edit an existing blog post./blog/delete?id={id}
: Delete a blog post.
- BlogController: Handles actions like listing blogs, creating, editing, and deleting.
- UserController: Manages user authentication (sign-in, sign-up, logout).
Contributions are welcome! Follow these steps to contribute:
- Fork this repo.
- Create a new branch (
git checkout -b feature/my-feature
). - Commit your changes (
git commit -m 'Added some feature'
). - Push to the branch (
git push origin feature/my-feature
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.
Made with ❤️ by [Ahmed Al-Sanadi]
⭐ Star this repo if you find it useful!