A complete judging system built using PHP, MySQL, and vanilla JavaScript. This is a full-stack application where:
- PHP files contain both backend logic and frontend templates.
- JavaScript is embedded directly in PHP files for simplicity.
- MySQL handles persistent data storage.
- PHP 8.0+
- MySQL 5.7+
- Apache/Nginx (or use PHP built-in server)
Access the live application here
- Clone the repository
git clone https://github.com/yourusername/judging-system.git cd judging-system # 2. Copy to web root (better than direct clone to /home/melody/Desktop/judging-systeml) sudo rsync -avz ./ //home/melody/Desktop/judging-system/--exclude='.git'
Set secure permissions sudo chown -R www-data:www-data /home/melody/Desktop/judging-system sudo find /home/melody/Desktop/judging-system -type d -exec chmod 755 {} ; sudo find /home/melody/Desktop/judging-system -type f -exec chmod 644 {} ;
Special permissions for writeable folders sudo chmod -R 775 /home/melody/Desktop/judging-system/storage # If you have logs/cache
2. **Create the database**
```bash
# Create database and user (MySQL example)
mysql -u root -p -e "CREATE DATABASE judging_system;"
mysql -u root -p -e "CREATE USER 'judge_app'@'localhost' IDENTIFIED BY 'securepassword';"
mysql -u root -p -e "GRANT ALL PRIVILEGES ON judging_system.* TO 'judge_app'@'localhost';"
# Import schema
mysql -u root -p judging_system < sql/schema.sql
# Optional: Load sample data
mysql -u root -p judging_system < sql/sample_data.sql
-
Configure database credentials
cp includes/config.example.php includes/config.php Edit includes/config.php with your database credentials: php <?php define('DB_HOST', 'localhost'); define('DB_NAME', 'judging_system'); define('DB_USER', 'judging_user'); define('DB_PASS', 'SecurePassword123!');
-
Start development server (PHP built-in)
php -S localhost:8000 router.php
Start Apache
sudo systemctl restart apache2
Database Connection Errors:
bash
mysql -u judge_app -psecurepassword judging_system -e "SHOW TABLES;" File Permissions:
bash chmod -R 755 storage/ logs/ chown -R www-data:www-data . # For Apache Missing Dependencies:
bash
sudo apt install php-mysql php-curl php-mbstring
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE judges (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
display_name VARCHAR(100) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE scores (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
judge_id INT NOT NULL,
score INT NOT NULL CHECK (score BETWEEN 1 AND 100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (judge_id) REFERENCES judges(id),
UNIQUE KEY unique_judge_user (judge_id, user_id)
);- Mixed Architecture: Each PHP file includes backend logic and HTML/CSS/JS.
- Why: Simpler and faster for small-scale LAMP stack apps.
- Database
- InnoDB for transactions
CHECKconstraints for score validation- Unique judge-user scoring enforced
- Security
- Prepared statements to prevent SQL injection
- Basic input sanitization
- JavaScript
- Vanilla JS directly embedded for DOM manipulation
- No authentication system (demo purposes only)
- Judges and participants are preloaded
- Running locally in PHP 8.0+ environment
If expanded further, features could include:
- Authentication (sessions or JWT)
- Decoupled frontend (React/Vue) with API
- CSV import/export
- WebSocket-based real-time updates
- Responsive design for mobile
- Automated testing suite
- Admin Panel:
/admin/→ Manage judges - Judge Portal:
/judges/→ Submit scores - Public Scoreboard:
/scoreboard/→ View results
MIT License