# Admin Panel — Installation Guide (cPanel Shared Hosting)

## What's included in this delivery
This is **Phase 1 of the project: the complete Admin Panel + Backend**, fully built and tested.
The public-facing website (homepage, exam pages, test-taking screen, Razorpay checkout, user login)
is being built next and will be delivered separately, connecting to the same database.

## Requirements
- PHP 8.0+ (tested on PHP 8.3)
- MySQL / MariaDB
- cPanel shared hosting (no SSH, no Composer, no Node.js needed)

## Step 1 — Create Database on cPanel
1. Go to **cPanel → MySQL Databases**
2. Create a new database, e.g. `yourcpaneluser_examdb`
3. Create a new database user with a strong password
4. Add the user to the database with **All Privileges**

## Step 2 — Import the schema
1. Go to **cPanel → phpMyAdmin**
2. Select your new database
3. Click **Import** and upload `database/schema.sql`
4. This creates all 17 tables and inserts default website settings

## Step 3 — Upload files
1. Upload the entire project folder to your hosting (e.g. `public_html/` or a subfolder)
2. Make sure file structure stays intact — `config/`, `includes/`, `admin/`, `install/`, `database/`

## Step 4 — Configure database connection
Open `config/database.php` and update these 3 lines with your actual cPanel database details:

```php
private const DB_NAME = 'yourcpaneluser_examdb';
private const DB_USER = 'yourcpaneluser_dbuser';
private const DB_PASS = 'your_strong_db_password';
```

## Step 5 — Set your live domain
Open `config/config.php` and update:

```php
define('BASE_URL', 'https://yourdomain.com/');
define('APP_ENV', 'production'); // change from 'development' to 'production'
```

## Step 6 — Create your admin account
1. Visit `https://yourdomain.com/install/create-admin.php` in your browser
2. Fill in your name, username, email, and a strong password
3. Click **Create Super Admin Account**
4. This screen automatically disables itself once one admin account exists (for security)

## Step 7 — Delete the install folder
**Important:** After creating your admin account, delete the entire `/install` folder from your server.
It is not needed again and should not remain publicly accessible.

## Step 8 — Login
Visit `https://yourdomain.com/admin/login.php` and log in with the account you just created.

## Step 9 — Configure your settings
From the admin panel, go to **Website Settings** and fill in:
- Website name, logo, contact info
- Razorpay Key ID & Key Secret (you can add these later once you're ready to take payments)
- Telegram/YouTube links
- SEO defaults

Then start adding your **Exam Categories → Mock Tests → Questions** from the sidebar.

## Security notes (already handled in code)
- `/config`, `/includes`, and `/database` folders are blocked from direct browser access via `.htaccess`
- All admin forms are protected with CSRF tokens
- Passwords are hashed with bcrypt
- Login has brute-force protection (5 failed attempts = 15 minute lockout)
- All database queries use PDO prepared statements (SQL-injection safe)
- All output is HTML-escaped (XSS safe)

## Default admin credentials used during testing (for your reference only — not present in delivered files)
None — the delivered `admins` table is empty. You must create your own account via Step 6.
