# 🚀 Hostinger Deployment Guide - Red Solo Cup 2026 ## ✅ What Works on Hostinger This application is **100% compatible** with Hostinger Shared Hosting (all plans): - ✅ PHP 7.4+ (included in all plans) - ✅ MySQL/MariaDB database (included in all plans) - ✅ Static HTML/CSS/JavaScript (included in all plans) - ✅ No special server required! ## 📦 Files You Need to Upload 1. **api.php** - Backend API (handles all database operations) 2. **red-solo-cup-2026.html** - Frontend interface 3. **.htaccess** - URL routing configuration (optional but recommended) ## 🔧 Setup Instructions ### Step 1: Create MySQL Database 1. **Login to Hostinger hPanel** - Go to https://hpanel.hostinger.com 2. **Navigate to Databases** - Click on "Databases" → "MySQL Databases" 3. **Create New Database** - Database name: `redsolocup` (or any name you prefer) - Click "Create" 4. **Create Database User** - Username: `redsolocup_admin` (or any name) - Password: Create a strong password - Click "Create User" 5. **Grant Privileges** - Select your database - Add your user with "ALL PRIVILEGES" - Click "Save" 6. **Note Your Credentials** ``` Database Host: localhost Database Name: uXXXXXXXX_redsolocup (Hostinger adds prefix) Database User: uXXXXXXXX_admin (Hostinger adds prefix) Database Password: [your password] ``` ### Step 2: Configure api.php 1. **Open api.php in a text editor** 2. **Update database credentials** (lines 13-16): ```php define('DB_HOST', 'localhost'); define('DB_NAME', 'uXXXXXXXX_redsolocup'); // Your actual database name define('DB_USER', 'uXXXXXXXX_admin'); // Your actual database username define('DB_PASS', 'YourActualPassword'); // Your actual database password ``` 3. **Save the file** ### Step 3: Upload Files to Hostinger **Option A: Using File Manager (Easiest)** 1. **Login to hPanel** → Go to "File Manager" 2. **Navigate to public_html** - This is your website root folder 3. **Create tournament folder** (optional but recommended) - Click "New Folder" - Name it: `tournament` or `betting` - Or use `public_html` directly 4. **Upload files** - Click "Upload Files" - Upload: `api.php` and `red-solo-cup-2026.html` **Option B: Using FTP** 1. **Get FTP credentials** from hPanel → "FTP Accounts" 2. **Use FTP client** (FileZilla, Cyberduck, etc.) - Host: ftp.yourdomain.com - Username: Your FTP username - Password: Your FTP password - Port: 21 3. **Upload files** to `public_html/tournament/` ### Step 4: Initialize Database **Open in your browser:** ``` https://yourdomain.com/tournament/api.php/init ``` You should see: ```json {"success":true,"message":"Database initialized"} ``` This creates all the required database tables! ### Step 5: Update HTML File **Edit red-solo-cup-2026.html:** Find the API base URL (search for "http://localhost:5000" or similar) and replace with: ```javascript const API_BASE_URL = '/tournament/api.php'; // Or if in root: const API_BASE_URL = '/api.php'; ``` ### Step 6: Test Your Application **Open in browser:** ``` https://yourdomain.com/tournament/red-solo-cup-2026.html ``` **Test these features:** 1. ✅ Register a player account 2. ✅ Login with that account 3. ✅ Login as admin (username: admin, password: bluemonster2026) 4. ✅ Create a game 5. ✅ Create a team 6. ✅ Place a bet ## 🎨 Optional: Clean URLs with .htaccess Create `.htaccess` file in your tournament folder: ```apache # Rewrite rules for cleaner URLs RewriteEngine On # Redirect index to main app DirectoryIndex red-solo-cup-2026.html # API routing RewriteRule ^api/(.*)$ api.php/$1 [L,QSA] # Force HTTPS (optional but recommended) RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] ``` Now you can access: - App: `https://yourdomain.com/tournament/` - API: `https://yourdomain.com/tournament/api/players` ## 🔒 Security Recommendations ### 1. Change Default Admin Password - Login as admin - Go to Settings → Manage Administrators - Create new admin with secure password - Delete default admin ### 2. Protect api.php from Direct Access (Optional) Add to `.htaccess`: ```apache # Only allow API access from your domain RewriteEngine On RewriteCond %{HTTP_REFERER} !^https://yourdomain\.com [NC] RewriteRule .* - [F,L] ``` ### 3. Use HTTPS Hostinger provides free SSL certificates: - Go to hPanel → SSL - Install free SSL certificate - Force HTTPS in .htaccess (see above) ## 📊 Database Management ### View Database via phpMyAdmin 1. **Login to hPanel** 2. **Go to "Databases" → "phpMyAdmin"** 3. **Select your database** 4. **View tables:** - players - teams - games - bets - admins - settings ### Backup Database **Automatic (Recommended):** - Hostinger backups are automatic on Premium/Business plans **Manual:** 1. Go to phpMyAdmin 2. Select your database 3. Click "Export" 4. Choose "Quick" export method 5. Download SQL file ### Restore Database 1. Go to phpMyAdmin 2. Select your database 3. Click "Import" 4. Choose your SQL backup file 5. Click "Go" ## 🐛 Troubleshooting ### "Database connection failed" **Solution:** - Check database credentials in api.php - Make sure database exists in hPanel - Verify user has privileges ### "500 Internal Server Error" **Solution:** - Check PHP error logs in hPanel - Verify file permissions (644 for .php files) - Make sure PHP version is 7.4+ in hPanel → PHP Configuration ### "CORS errors" in browser console **Solution:** - Make sure api.php has proper CORS headers (already included) - If still issues, contact Hostinger support about CORS ### Can't access /init endpoint **Solution:** - Try: `yourdomain.com/tournament/api.php?action=init` - Or use phpMyAdmin to manually run SQL from api.php ### Players can't register **Check:** 1. Database is initialized (`/api.php/init`) 2. Database credentials are correct 3. Tables exist (check phpMyAdmin) 4. PHP errors (check error logs in hPanel) ## 📱 Mobile Access Your tournament app is automatically mobile-responsive! Players can access from phones/tablets: ``` https://yourdomain.com/tournament/ ``` Share this link with all players! ## 🎯 API Endpoints Reference All endpoints are accessed via `api.php`: **Players:** - POST `/api.php/players/register` - Register new player - POST `/api.php/players/login` - Login player - GET `/api.php/players` - Get all players - PUT `/api.php/players/{id}` - Update player - DELETE `/api.php/players/{id}` - Delete player **Teams:** - GET `/api.php/teams` - Get all teams - POST `/api.php/teams` - Create team - DELETE `/api.php/teams/{id}` - Delete team **Games:** - GET `/api.php/games` - Get all games - POST `/api.php/games` - Create game - DELETE `/api.php/games/{id}` - Delete game **Bets:** - GET `/api.php/bets` - Get all bets - GET `/api.php/bets?player_id={id}` - Get player's bets - POST `/api.php/bets` - Place bet - DELETE `/api.php/bets/{id}` - Delete bet **Admins:** - POST `/api.php/admins/login` - Admin login - GET `/api.php/admins` - Get all admins - POST `/api.php/admins` - Create admin - DELETE `/api.php/admins/{id}` - Delete admin **Settings:** - GET `/api.php/settings` - Get all settings - POST `/api.php/settings` - Update settings ## 💰 Hostinger Plan Recommendations **✅ Premium Web Hosting ($2.99/mo)** - Perfect for this application - 100GB SSD storage - 100 MySQL databases - Free SSL certificate - **Recommended for tournaments** **✅ Business Web Hosting ($3.99/mo)** - Everything in Premium - Daily backups - Better performance - **Best for large tournaments** **❌ Single Web Hosting ($1.99/mo)** - Works but limited (1 website, 30GB storage) - Okay for testing ## 🎉 You're Done! Your Red Solo Cup 2026 tournament betting system is now live on Hostinger! **Share with players:** ``` https://yourdomain.com/tournament/ ``` **Admin access:** ``` Username: admin Password: bluemonster2026 ``` **Change admin password immediately!** --- Need help? Check Hostinger's support or PHP error logs in hPanel!