# DEPLOYMENT CHECKLIST - Print This! ✅

## Before You Deploy to cPanel

### Step 1: Test on Localhost ✓
- [ ] Navigate to admin_login.php on localhost
- [ ] Login with your admin credentials
- [ ] Navigate to Products section
- [ ] Add a new product and click Save
  - [ ] Verify success message appears
  - [ ] Close browser tab
  - [ ] Open admin panel again
  - [ ] Verify new product still appears
- [ ] Edit the product and click Save
  - [ ] Verify success message appears
  - [ ] Refresh page
  - [ ] Verify changes persisted
- [ ] Delete a product
  - [ ] Verify success message appears
  - [ ] Refresh page
  - [ ] Verify product is gone

### Step 2: Test Carousel Upload
- [ ] Navigate to Manage Carousel in admin
- [ ] Add a carousel category
- [ ] Test URL field:
  - [ ] Enter an image URL
  - [ ] Click Save
  - [ ] Verify success message
  - [ ] Refresh page
  - [ ] Verify URL saved
- [ ] Test File Upload field:
  - [ ] Click "Choose File"
  - [ ] Select an image from your computer
  - [ ] Click Save
  - [ ] Verify success message
  - [ ] Verify image appears in preview

### Step 3: Test Other Admin Functions
- [ ] Dashboard → Change site title → Save
- [ ] Dashboard → Add social media link → Save
- [ ] Manage Slider → Add slider image → Save
- [ ] Manage Marquee → Change text → Save
- [ ] Each time verify:
  - [ ] Success message appears
  - [ ] Refresh page
  - [ ] Data still there

### Step 4: Run Verification Test
- [ ] Open: http://localhost/emporio-sport/test_deployment.php
- [ ] Verify ALL tests show ✓ PASS
- [ ] If any test fails:
  - [ ] Do NOT proceed to cPanel
  - [ ] Check error messages
  - [ ] Fix issues locally first

### Step 5: Check Error Logs
- [ ] Open PHP error log
  - [ ] On Windows: look in xampp/logs/ folder
  - [ ] Search for "error" in the log
  - [ ] Search for "DatabaseHelper" in the log
  - [ ] If errors found: fix them first

---

## Prepare for cPanel Upload

### Step 6: Gather cPanel Credentials
- [ ] cPanel URL (example.com/cpanel or cp.example.com)
- [ ] cPanel username
- [ ] cPanel password
- [ ] FTP hostname (usually ftp.yourdomain.com)
- [ ] FTP username
- [ ] FTP password (usually same as cPanel)
- [ ] Your domain name (where site will be)

### Step 7: Prepare Files for Upload
- [ ] Verify all files are ready in: C:\xampp\htdocs\emporio-sport\
- [ ] Make sure these files exist:
  - [ ] helpers/database_helper.php (CRITICAL!)
  - [ ] admin_products.php
  - [ ] admin_add_product.php
  - [ ] admin_edit_product.php
  - [ ] admin_dashboard.php
  - [ ] admin_manage_carousel.php (has file upload)
  - [ ] shop.php and other public pages
  - [ ] index.php / home page
  - [ ] All CSS, JS, image files

---

## Deploy to cPanel

### Step 8: Upload Files via FTP

**If using FileZilla:**
- [ ] Open FileZilla
- [ ] Go to File → Site Manager
- [ ] Click "New Site"
- [ ] Host: ftp.yourdomain.com
- [ ] Username: (your FTP username)
- [ ] Password: (your FTP password)
- [ ] Click "Connect"
- [ ] Navigate to: /home/username/public_html/ (or your domain folder)
- [ ] Upload all files from C:\xampp\htdocs\emporio-sport\

**If using cPanel File Manager:**
- [ ] Login to cPanel
- [ ] Go to File Manager
- [ ] Navigate to public_html folder
- [ ] Click "Upload"
- [ ] Select all files from C:\xampp\htdocs\emporio-sport\
- [ ] Click "Upload"

### Step 9: Create Directories on cPanel
- [ ] Using cPanel File Manager or SSH:
  - [ ] Create folder: /data
  - [ ] Create folder: /uploads
- [ ] If using SSH:
  ```bash
  mkdir ~/public_html/data
  mkdir ~/public_html/uploads
  ```

### Step 10: Set Permissions
- [ ] Using cPanel File Manager:
  - [ ] Right-click /data folder
  - [ ] Click "Change Permissions"
  - [ ] Set to: 755
  - [ ] Click "Change"
  - [ ] Repeat for /uploads folder
  
- [ ] If using SSH:
  ```bash
  chmod 755 ~/public_html/data
  chmod 755 ~/public_html/uploads
  chmod 644 ~/public_html/data/*.json
  ```

---

## Verify cPanel Installation

### Step 11: Run Verification Test
- [ ] Open: yourdomain.com/test_deployment.php
- [ ] Wait for page to load
- [ ] Verify ALL tests show ✓ PASS
- [ ] Note any failures:
  - [ ] If "Data directory not found":
    - [ ] Create /data directory
    - [ ] Set permissions to 755
  - [ ] If "Uploads directory not writable":
    - [ ] Check /uploads exists
    - [ ] Set permissions to 755
  - [ ] If "Products loading failed":
    - [ ] Check /data directory is writable
    - [ ] Check file permissions

### Step 12: Test Admin Panel on cPanel
- [ ] Open: yourdomain.com/admin_login.php
- [ ] Login with admin credentials
- [ ] Try to add a product
  - [ ] Enter product name and details
  - [ ] Click Save
  - [ ] Verify success message appears
  - [ ] Check that no errors show
- [ ] Refresh page
  - [ ] Verify product still appears
  - [ ] Verify data persisted on cPanel
- [ ] Try carousel file upload
  - [ ] Go to Manage Carousel
  - [ ] Upload an image file
  - [ ] Verify success message
  - [ ] Refresh page
  - [ ] Verify image saved

### Step 13: Test Frontend
- [ ] Open: yourdomain.com/
- [ ] Verify site displays correctly
- [ ] Click Shop → Verify products display
- [ ] Click Product → Verify product details load
- [ ] Check that all styling looks right
- [ ] Test contact form (optional)

### Step 14: Check for Errors
- [ ] Login to cPanel
- [ ] Go to Metrics → Error log
- [ ] Search for "error" or "Error"
- [ ] Search for "DatabaseHelper"
- [ ] If errors found:
  - [ ] Note the error message
  - [ ] Check /data and /uploads permissions
  - [ ] Check that directories exist
  - [ ] Try running test_deployment.php again

---

## Post-Deployment

### Step 15: Final Verification
- [ ] Site loads correctly
- [ ] Admin panel accessible
- [ ] Can add/edit products
- [ ] Can upload carousel images
- [ ] All data persists
- [ ] No errors in error log
- [ ] Contact form works (if applicable)

### Step 16: Secure Your Site
- [ ] Delete test_deployment.php (optional - keep for troubleshooting)
- [ ] Set strong passwords for admin
- [ ] Configure email settings
- [ ] Set up SSL/HTTPS (in cPanel)
- [ ] Create backups of your data

### Step 17: Test from Customer Perspective
- [ ] Browse site as customer
- [ ] Add items to cart
- [ ] Go through checkout
- [ ] Verify everything works
- [ ] Check on mobile device
- [ ] Check in different browsers

### Step 18: Create Backup
- [ ] In cPanel: Create full backup
- [ ] Or download via FTP:
  - [ ] Download /data/ folder
  - [ ] Download /uploads/ folder
  - [ ] Store on your computer

---

## Troubleshooting Quick Fixes

### Problem: "Error saving data"
```
Solution:
  1. Check /data directory exists
  2. Set permissions: chmod 755 /data
  3. Check files: chmod 644 /data/*.json
  4. Run test_deployment.php to find exact issue
```

### Problem: "Permission denied"
```
Solution:
  1. Check directory permissions: chmod 755 /data /uploads
  2. Check file permissions: chmod 644 /data/*.json
  3. Make sure you own the files (not root)
```

### Problem: File upload not working
```
Solution:
  1. Check /uploads directory exists: mkdir /uploads
  2. Set permissions: chmod 755 /uploads
  3. Check PHP upload settings in cPanel
  4. File size limit should be ≥ 5MB
```

### Problem: Data not saving
```
Solution:
  1. Run: yourdomain.com/test_deployment.php
  2. Check which test fails
  3. Check cPanel error log
  4. Verify /data directory is writable
  5. Check that files uploaded successfully
```

### Problem: Old data showing on page
```
Solution (OPCache issue):
  1. Clear browser cache (Ctrl+Shift+Del)
  2. Logout and login admin again
  3. If still showing old data:
     - Access cPanel PHP settings
     - Disable OPCache temporarily
     - Save new data
     - Re-enable OPCache
```

---

## Emergency Procedures

### If Something Breaks on cPanel

**Option 1: Restore from Backup**
```
1. Download backup of /data/ folder
2. Delete files in /data/ on cPanel
3. Upload backed up files
4. Test admin panel again
```

**Option 2: Start Fresh**
```
1. Delete all .json files in /data/
2. DatabaseHelper will create new ones with defaults
3. You'll need to re-add products
4. But site will work again
```

**Option 3: Get Help**
```
1. Run: yourdomain.com/test_deployment.php
2. Note which test fails
3. Check error log: yourdomain.com/error_log
4. Screenshot the error
5. Reference this with your hosting provider
```

---

## Important Phone Numbers & Info

**Save These!**
```
cPanel Login: __________________________________
cPanel Password: _______________________________
FTP Host: _____________________________________
FTP Username: _________________________________
FTP Password: _________________________________
Domain: _______________________________________
Hosting Provider: _____________________________
Support Email: ________________________________
Support Phone: ________________________________
```

---

## Success! ✅

When everything is working:

- [ ] Admin panel accessible
- [ ] Can add/edit/delete products
- [ ] Carousel file upload works
- [ ] Site displays correctly
- [ ] No errors in error log
- [ ] Data persists after refresh
- [ ] test_deployment.php shows all pass

**Your site is now live on cPanel! 🎉**

---

## Keep These Files Handy

**For Reference:**
- CPANEL_DEPLOYMENT_GUIDE.md - Detailed steps
- SESSION_SUMMARY.md - What was changed
- QUICK_REFERENCE.md - Quick status
- test_deployment.php - Verification tool

---

Date Deployed: ________________
Deployed By: ________________
Site URL: ________________
Deployment Notes: _________________________________
_____________________________________________
_____________________________________________
