img

Onlinevoting System Project In Php And Mysql Source Code Github Portable

Online Voting System Project in PHP and MySQL

An online voting system is a web-based application that allows users to cast their votes electronically. This project aims to provide a secure, efficient, and transparent way of conducting online elections.

Features:

  1. User Registration: Users can register to vote by providing their details.
  2. Login System: Users can log in to cast their votes.
  3. Voting System: Users can cast their votes for a particular candidate.
  4. Candidate Management: Admin can add, edit, and delete candidates.
  5. Result Management: Admin can view the voting results.

Source Code on GitHub:

You can find the source code for this project on GitHub:

Repository: https://github.com/your-username/online-voting-system

Database Schema:

The database schema for this project is as follows:

CREATE TABLE users (
  id INT PRIMARY KEY AUTO_INCREMENT,
  name VARCHAR(255),
  email VARCHAR(255),
  password VARCHAR(255)
);
CREATE TABLE candidates (
  id INT PRIMARY KEY AUTO_INCREMENT,
  name VARCHAR(255),
  description TEXT
);
CREATE TABLE votes (
  id INT PRIMARY KEY AUTO_INCREMENT,
  user_id INT,
  candidate_id INT,
  FOREIGN KEY (user_id) REFERENCES users(id),
  FOREIGN KEY (candidate_id) REFERENCES candidates(id)
);

PHP Code:

The PHP code for this project is as follows:

config.php

<?php
  $host = 'localhost';
  $username = 'your_username';
  $password = 'your_password';
  $database = 'online_voting_system';
$conn = mysqli_connect($host, $username, $password, $database);
if (!$conn) 
    die("Connection failed: " . mysqli_connect_error());
?>

register.php

<?php
  include 'config.php';
if (isset($_POST['register'])) 
    $name = $_POST['name'];
    $email = $_POST['email'];
    $password = $_POST['password'];
$query = "INSERT INTO users (name, email, password) VALUES ('$name', '$email', '$password')";
    $result = mysqli_query($conn, $query);
if ($result) 
      header('Location: login.php');
     else 
      echo "Error: " . mysqli_error($conn);
?>

login.php

<?php
  include 'config.php';
if (isset($_POST['login'])) 
    $email = $_POST['email'];
    $password = $_POST['password'];
$query = "SELECT * FROM users WHERE email = '$email' AND password = '$password'";
    $result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) > 0) 
      header('Location: index.php');
     else 
      echo "Invalid email or password";
?>

index.php

<?php
  include 'config.php';
if (isset($_POST['vote'])) 
    $candidate_id = $_POST['candidate_id'];
    $user_id = $_SESSION['user_id'];
$query = "INSERT INTO votes (user_id, candidate_id) VALUES ('$user_id', '$candidate_id')";
    $result = mysqli_query($conn, $query);
if ($result) 
      echo "Vote cast successfully";
     else 
      echo "Error: " . mysqli_error($conn);
?>

Portable Version:

To make this project portable, you can use a tool like XAMPP or WAMP to create a local server on your machine. You can also use a portable MySQL database like SQLite.

Security Measures:

  1. Password Hashing: Use a secure password hashing algorithm like bcrypt to store passwords.
  2. CSRF Protection: Use a token-based system to prevent cross-site request forgery (CSRF) attacks.
  3. Input Validation: Validate user input to prevent SQL injection and cross-site scripting (XSS) attacks.

This is a basic online voting system project in PHP and MySQL. You can improve it by adding more features and security measures. You can also use a framework like Laravel or CodeIgniter to make it more robust and scalable.

Several online voting system projects built with PHP and MySQL are available on GitHub, offering features like admin panels and secure voter registration

. These systems typically run on local server environments like , making them highly portable and easy to set up Popular GitHub Repositories php-voting-system

: Includes an AdminLTE theme for a professional dashboard and handles election management through a full admin panel University-Online-Voting-System

: A structured project designed for campus elections, featuring clear installation steps and a pre-configured database schema Online-Voting-System-using-php-and-mysql

: A basic, open-source implementation focused on core voting functionality like candidate listing and real-time vote counts Standard Features Most of these portable projects include: Voter Registration & Login : Validates users before they can cast a vote Admin Dashboard

: Allows admins to create elections, manage candidate profiles, and monitor results Real-time Results

: Automatically calculates and displays voting tallies as they come in Installation Guide (General) To run these projects portably on your local machine: Install a Local Server : Download and start (Apache and MySQL) Download Source Code : Clone or download the ZIP from the GitHub repo and place it in the Setup Database phpMyAdmin to create a new database and import the file included in the project folder : Access the system via localhost/your_folder_name in your web browser php-voting-system · GitHub Topics Online Voting System Project in PHP and MySQL

Online Voting System using PHP and Mysql with AdminLTE Theme. online-voting-with-admin-panel. Updated on Mar 31, 2023. online-voting-system · GitHub Topics


3. System Requirements

8. Security Features

Step-by-Step Installation

1. Download the Source Code You can clone or download the repository from GitHub.

Search for the repository or use the link provided at the end of this post.

2. Extract the Files

3. Create the Database

4. Configure the Connection

5. Run the Application


Customization Ideas to Extend the Project

Once you have the base portable voting system, you can add: User Registration : Users can register to vote

  1. Email Verification – Send OTP via PHPMailer before approving voters.
  2. Two-Factor Authentication – Google Authenticator integration.
  3. QR Code Voting – Generate unique QR for each voter.
  4. Blockchain-inspired Audit Log – Store vote hashes in a separate table.
  5. Export Results as PDF/CSV – Using FPDF or PhpSpreadsheet.
  6. Live Vote Count Chart – Use Chart.js to show real-time graphs.
  7. Multi-language Support – Store language strings in MySQL.

These additions maintain portability as long as no server-specific extensions (beyond PHP/MySQL) are required.