A modern and secure web-based voting system built with PHP and MySQL, featuring a responsive design and real-time vote tracking.
- PHP 7.4+ - Server-side scripting language
- MySQL 5.7+ - Database management system
- Apache 2.4+ - Web server
- PDO - Database abstraction layer
- Bootstrap 5 - Frontend framework
- Chart.js - Data visualization
- Bootstrap Icons - Icon library
- HTML5 - Markup language
- CSS3 - Styling
- JavaScript - Client-side scripting
- Bootstrap 5 - UI components and layout
- jQuery - DOM manipulation and AJAX
- Font Awesome - Icons
-
User Authentication
- Secure login and registration
- Role-based access control (Admin and Voter roles)
- Session management
-
Voting Management
- Real-time vote tracking
- Multiple position support
- Candidate profiles with images and bios
- Vote time restrictions
- One vote per user enforcement
-
Admin Features
- Dashboard with voting statistics
- Candidate management (Add, Edit, Delete)
- Position management
- Voting time settings
- User management
- Results monitoring
-
Security Features
- Password hashing
- SQL injection prevention
- XSS protection
- CSRF protection
- Session security
- PHP 7.4 or higher
- MySQL 5.7 or higher
- Apache Web Server
- Modern web browser with JavaScript enabled
- mod_rewrite enabled (Apache)
- PHP Extensions:
- PDO
- PDO_MySQL
- GD (for image processing)
- mbstring
- json
-
Database Setup
CREATE DATABASE meddy_voting_system; USE meddy_voting_system;
-
Configure Database Connection
- Navigate to
config/config.php - Update database credentials:
define('DB_HOST', 'localhost'); define('DB_USER', 'your_username'); define('DB_PASS', 'your_password'); define('DB_NAME', 'meddy_voting_system');
- Navigate to
-
File Permissions
# Set directory permissions chmod 755 -R /path/to/meddy_voting_system chmod 777 -R /path/to/meddy_voting_system/uploads chmod 777 -R /path/to/meddy_voting_system/logs -
Initial Setup
- Import the database schema
- Create an admin account
- Configure voting settings
-
Using XAMPP/WAMP/MAMP
# 1. Install XAMPP/WAMP/MAMP # 2. Place the project in the web server directory: # XAMPP: C:\xampp\htdocs\meddy_voting_system # WAMP: C:\wamp\www\meddy_voting_system # MAMP: /Applications/MAMP/htdocs/meddy_voting_system # 3. Start the servers # - Start Apache # - Start MySQL # 4. Access the application http://localhost/meddy_voting_system
-
Using Docker (Alternative)
# 1. Install Docker and Docker Compose # 2. Create docker-compose.yml version: '3' services: web: image: php:7.4-apache ports: - "8080:80" volumes: - ./:/var/www/html db: image: mysql:5.7 environment: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: meddy_voting_system ports: - "3306:3306" # 3. Run the containers docker-compose up -d # 4. Access the application http://localhost:8080
-
Apache Configuration
# .htaccess in the project root RewriteEngine On RewriteBase /meddy_voting_system/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
-
PHP Configuration
# php.ini settings upload_max_filesize = 10M post_max_size = 10M max_execution_time = 300 memory_limit = 256M
-
Database Configuration
-- Create a dedicated database user CREATE USER 'meddy_user'@'localhost' IDENTIFIED BY 'secure_password'; GRANT ALL PRIVILEGES ON meddy_voting_system.* TO 'meddy_user'@'localhost'; FLUSH PRIVILEGES;
-
First-time Setup
# 1. Access the application http://your-domain/meddy_voting_system # 2. Create admin account - Navigate to /register.php - Register as admin - Set up voting settings
-
Regular Usage
# 1. Start the servers - Start Apache - Start MySQL # 2. Access the application http://your-domain/meddy_voting_system # 3. Admin tasks - Login to admin dashboard - Manage positions and candidates - Configure voting times # 4. Voter tasks - Register/Login - Cast votes - View results
-
Maintenance
# 1. Regular backups mysqldump -u username -p meddy_voting_system > backup.sql # 2. Log monitoring tail -f /path/to/error.log # 3. Security updates - Update PHP - Update MySQL - Update dependencies
- Install the following software:
-
Clone the Repository
git clone https://github.com/your-repo/meddy_voting_system.git cd meddy_voting_system -
Set Up the Database
- Create a new database in MySQL named
meddy_voting_system. - Import the
schema.sqlfile located in theconfig/directory into the database.
- Create a new database in MySQL named
-
Configure the Application
- Open
config/config.phpand update the database credentials:define('DB_HOST', 'localhost'); define('DB_USER', 'your_username'); define('DB_PASS', 'your_password'); define('DB_NAME', 'meddy_voting_system');
- Open
-
Start the Server
- Place the project folder in your web server's root directory:
- For XAMPP:
C:\xampp\htdocs\meddy_voting_system - For WAMP:
C:\wamp\www\meddy_voting_system
- For XAMPP:
- Start Apache and MySQL services from the control panel.
- Place the project folder in your web server's root directory:
-
Access the Application
- Open your browser and navigate to:
http://localhost/meddy_voting_system
- Open your browser and navigate to:
-
Create an Admin Account
- Navigate to the registration page (
/register.php). - Register as an admin to access the admin dashboard.
- Navigate to the registration page (
-
Set Up Voting
- Log in as an admin.
- Add positions and candidates.
- Configure voting time settings.
-
Test the Application
- Register as a voter.
- Log in and cast your vote.
- View results on the results page.
- Check the
logs/error.logfile for any errors. - Ensure the database credentials in
config/config.phpare correct. - Verify that Apache and MySQL services are running.
For further assistance, refer to the Support section.
- Login with admin credentials
- Access the admin dashboard
- Manage positions and candidates
- Configure voting times
- Monitor results
- Register/Login with voter account
- View available positions and candidates
- Cast votes during active voting period
- View results (if enabled)
meddy_voting_system/
├── admin/ # Admin control panel
├── assets/ # CSS, JS, and images
├── config/ # Configuration files
├── includes/ # PHP includes
├── uploads/ # Uploaded images
└── vendor/ # Dependencies
- Keep PHP and MySQL updated
- Use HTTPS in production
- Regularly backup the database
- Monitor error logs
- Update passwords periodically
- Implement rate limiting
- Use prepared statements
- Vote recording may require additional debugging
- Working on improving transaction handling
- Enhancing error reporting
- Enhanced vote verification
- Email notifications
- Two-factor authentication
- Improved analytics
- Ballot preview
- Vote receipt generation
- API integration
- Audit logging
For issues and support:
- Create an issue in the repository
- Contact system administrator
- Check error logs in the server
This project is licensed under the MIT License - see the LICENSE file for details.
Developed and maintained by [Your Organization/Name]
- v1.0.0 - Initial release
- Basic voting functionality
- Admin dashboard
- User authentication
- Fork the repository
- Create a feature branch
- Commit changes
- Push to the branch
- Create a Pull Request