# How to Deploy Your Portfolio to cPanel

Follow these steps to upload your dynamic PHP website and Admin Panel to your cPanel hosting.

## Step 1: Prepare Your Files
1.  On your computer, select all the files and folders in your project (`index.php`, `admin/`, `css/`, `js/`, `images/`, `db_connect.php`, etc.).
2.  **Right-click** and zip them into a single file (e.g., `portfolio_site.zip`).
    *   *Note: Do not zip the parent folder, zip the contents inside it.*

## Step 2: Create a MySQL Database
1.  Log in to your **cPanel**.
2.  Go to the **Databases** section and click **MySQL® Database Wizard**.
3.  **Step 1: Create A Database**
    *   Enter a name (e.g., `mhmuhib_portfolio`).
    *   Click **Next Step**.
4.  **Step 2: Create Database Users**
    *   Enter a username (e.g., `mhmuhib_admin`).
    *   Enter a strong password (save this for later!).
    *   Click **Create User**.
5.  **Step 3: Add User to Database**
    *   Check the box **ALL PRIVILEGES**.
    *   Click **Make Changes**.
    *   **Important:** Write down the **Database Name**, **Database Username**, and **Password**. You will need these in Step 5.

## Step 3: Import the Database Tables
1.  Go back to the cPanel Dashboard.
2.  Click **phpMyAdmin** (under Databases).
3.  On the left sidebar, click on the database you just created (e.g., `yourusername_mhmuhib_portfolio`).
4.  Click the **Import** tab at the top.
5.  Click **Choose File** and select the `database.sql` file from this project.
6.  Click **Go** at the bottom.
    *   *Success! Your database tables (users, projects, blogs, settings) are now created.*

## Step 4: Upload Files
1.  Go to cPanel Dashboard > **File Manager**.
2.  Navigate to `public_html`.
    *   *If you want the site to be on the main domain, upload here.*
    *   *If you have old files here, you might want to back them up and delete them first.*
3.  Click **Upload** in the top toolbar.
4.  Select your `portfolio_site.zip` file.
5.  Once uploaded, go back to File Manager, right-click the zip file, and choose **Extract**.
6.  Extract them to `public_html`.

## Step 5: Connect PHP to Database
1.  In File Manager, find the file `db_connect.php`.
2.  Right-click it and select **Edit**.
3.  Update the values with the details from **Step 2**:

```php
$host = 'localhost';
$dbname = 'yourcpanelusername_mhmuhib_portfolio'; // Update this
$username = 'yourcpanelusername_mhmuhib_admin';   // Update this
$password = 'YourStrongPassword123!';             // Update this
```

4.  Click **Save Changes**.

## Step 6: Login to Admin Panel
1.  Visit your website: `https://yourdomain.com/admin`
2.  Login with the default credentials:
    *   **Username:** `admin`
    *   **Password:** `password`
3.  **Important:** Once logged in, you should implement a way to change your password or manually update the password hash in the `users` table via phpMyAdmin for security.

## Troubleshooting
*   **500 Error:** Check your `db_connect.php` credentials carefully.
*   **Images not showing:** Ensure the `images/` folder was uploaded and extracted correctly.
*   **Changes not showing:** Clear your browser cache or try an Incognito window.

## Updating an Existing Installation
If you are updating the site:
1.  Upload the new files.
2.  Open your browser and visit `https://yourdomain.com/update_db.php`.
    *   This will add the new tables and columns required for the latest features.
3.  Once the update is complete (it will say "Database update completed successfully"), you should delete `update_db.php` from the server for security.
