# Troubleshooting Guide - Admin Panel Issues ## Common Issues and Solutions ### Issue 1: Admin Panel Not Loading / Blank Page **Possible Causes:** 1. Database not created 2. Database connection failed 3. Missing files 4. PHP errors **Solutions:** 1. **Check Database:** - Open phpMyAdmin (http://localhost/phpmyadmin) - Check if database `lancet_exam_system` exists - If not, import `sql/database.sql` 2. **Check Database Credentials:** - Open `config/database.php` - Verify: - DB_HOST: `localhost` - DB_USER: `root` (or your MySQL username) - DB_PASS: `` (or your MySQL password) - DB_NAME: `lancet_exam_system` 3. **Run Diagnostic Test:** - Access: `http://localhost/Lancetclasses/admin/test.php` - This will show what's wrong 4. **Check PHP Errors:** - Open `config/config.php` - Ensure `error_reporting(E_ALL);` and `ini_set('display_errors', 1);` are enabled - Check browser console for JavaScript errors ### Issue 2: Cannot Login to Admin Panel **Possible Causes:** 1. Admin account not created 2. Wrong password 3. Database not imported **Solutions:** 1. **Check Admin Account:** ```sql SELECT * FROM admins; ``` - Should show at least one admin with username `admin` - If empty, import `sql/database.sql` again 2. **Default Credentials:** - Username: `admin` - Password: `admin123` 3. **Reset Admin Password (if needed):** ```sql UPDATE admins SET password = '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi' WHERE username = 'admin'; ``` (This sets password to `admin123`) ### Issue 3: Database Connection Error **Error Message:** "Database connection failed" **Solutions:** 1. **Check MySQL Service:** - Open XAMPP Control Panel - Ensure MySQL is running (green) 2. **Check Database Name:** - Database must be named exactly: `lancet_exam_system` - Case-sensitive on Linux/Mac 3. **Check User Permissions:** - Ensure MySQL user has CREATE, SELECT, INSERT, UPDATE, DELETE permissions 4. **Test Connection Manually:** ```php getMessage(); } ?> ``` ### Issue 4: Session Errors **Error:** "Session ini settings cannot be changed" **Solution:** - Already fixed in `config/config.php` - Session settings are now set before session_start() ### Issue 5: Page Shows "Access Denied" or Redirects **Possible Causes:** 1. Not logged in 2. Session expired 3. CSRF token mismatch **Solutions:** 1. **Clear Browser Cookies:** - Clear cookies for localhost - Try again 2. **Check Session:** - Ensure cookies are enabled in browser - Check if session files are being created in `C:\xampp\tmp\` (Windows) 3. **Check File Permissions:** - Ensure PHP can write to temp directory ### Issue 6: CSS/JavaScript Not Loading **Symptoms:** - Page loads but looks unstyled - Buttons/icons not showing **Solutions:** 1. **Check SITE_URL:** - Open `config/config.php` - Ensure `SITE_URL` matches your actual URL: ```php define('SITE_URL', 'http://localhost/Lancetclasses'); ``` 2. **Check File Paths:** - Verify `assets/css/custom.css` exists - Verify `assets/js/custom.js` exists 3. **Check Browser Console:** - Press F12 - Check Console tab for 404 errors - Fix paths accordingly ### Issue 7: File Upload Not Working **Solutions:** 1. **Check Upload Directory:** - Ensure `uploads/` folder exists - Ensure subfolders exist: `uploads/photos/`, `uploads/materials/`, `uploads/marksheets/` 2. **Check Permissions:** - On Windows: Usually not an issue - On Linux: `chmod 755 uploads` and subfolders 3. **Check PHP Settings:** - `upload_max_filesize` in php.ini - `post_max_size` in php.ini - Should be at least 10M ### Quick Diagnostic Steps 1. **Access Diagnostic Page:** ``` http://localhost/Lancetclasses/admin/test.php ``` 2. **Check Error Logs:** - XAMPP: `C:\xampp\apache\logs\error.log` - PHP: `C:\xampp\php\logs\php_error_log` 3. **Verify Installation:** - Database imported: ✓ - Config files exist: ✓ - Upload folders exist: ✓ - Admin account exists: ✓ ### Still Having Issues? 1. **Enable Full Error Display:** ```php // In config/config.php error_reporting(E_ALL); ini_set('display_errors', 1); ``` 2. **Check PHP Version:** - Required: PHP 7.4 or higher - Check: `` 3. **Check Required Extensions:** - PDO - PDO_MySQL - GD (for image handling) - mbstring 4. **Test Basic PHP:** - Create `test.php` in root: ```php ``` - If this doesn't work, PHP is not configured correctly --- ## Contact Support If issues persist: 1. Run diagnostic test: `admin/test.php` 2. Check error logs 3. Note exact error messages 4. Check browser console for JavaScript errors