# cPanel Deployment Guide for HSE Management

## 1. Upload files

- Upload the project root contents to your cPanel `public_html` or target web folder.
- Keep these important directories and files together:
  - `HSE_management.html.html`
  - `api/`
  - `config/`
  - `pictures/`

## 2. Database configuration

Open `config/database.php` and set your cPanel MySQL credentials:

```php
$DB_HOST = getenv('DB_HOST') ?: 'localhost';
$DB_NAME = getenv('DB_NAME') ?: 'hse_management';
$DB_USER = getenv('DB_USER') ?: 'hse_user';
$DB_PASS = getenv('DB_PASS') ?: 'your_password_here';
```

If your cPanel account supports environment variables, set:
- `DB_HOST`
- `DB_NAME`
- `DB_USER`
- `DB_PASS`

Otherwise, replace the fallback values with your actual cPanel database values.

## 3. Create the database

Use phpMyAdmin or cPanel MySQL Databases to create a database and user.

- Create a database, for example `hse_management`
- Create a user and assign it to the database with all privileges
- Use those credentials in `config/database.php`

## 4. Initialize the schema

Run `database_setup.sql` in phpMyAdmin to create the core tables used by the application.

If your database already exists, the script will create only missing tables.

## 5. Verify file paths

- The frontend uses relative API paths like `api/add_personnel.php`.
- Place the `api/` folder next to `HSE_management.html.html`.
- If you want the app to open by default, rename `HSE_management.html.html` to `index.html` or create an `index.html` redirect page.

## 6. Optional: use `index.html`

If you prefer the site to load automatically from the root, rename or copy `HSE_management.html.html` to `index.html`.

## 7. Troubleshooting

- If the app does not connect, check `config/database.php` credentials.
- If PPE fields are not saving, verify the `ppe_inventory` table includes the form fields used by the frontend.
- If login fails, verify the `users` table exists and the `login.php` endpoint is reachable.

## 8. Recommended next step

After uploading and configuring, open the app URL and test these actions:
- Add a personnel record
- Add PPE inventory
- Verify data is visible in the backend tables via phpMyAdmin

If any field is missing, update the database schema manually or rerun the SQL script after creating the missing table.
