Online Voting System Project
Online Voting System Project
ON
“ONLINE VOTING SYSTEM”
PARTIAL FULFILMENT OF THE REQUIREMENT FOR THE DEGREE OF
BACHELOR OF TECHNOLOGY
IN
1
lOM oARcP SD| 39 87 380 5
ACKNOWLEDGEMENT
I express my sincere gratitude to “Prof. Manoj Chaudhary Sir” worthy HOD for providing
me an opportunity to undergo this Major Project as the part of the curriculum.
It is my pleasure to be indebted to various people, who directly or indirectly contributed in
the development of this work and who influenced my thinking, behavior and acts during this
course of study.
Lastly, I would like to thank the almighty and my parents for their moral support and friends
with whom I shared my day-to day experience and received lots of suggestions that
improves my quality of work.
DATE:-
PLACE:-
lOMoARcPSD|39873805
TABLE OF CONTENTS
S.NO. PAGE
DESCRIPTION NO.
1. Acknowledgement………………………………………………... i
2. Candidate’s Declaration………………………………………….. ii
1.1. Overview……………………………………………..….
1.2. Objective …………………………………………….…..
1.3. Problem Definition …………………………………….
1.4. Problem Identification …………………………………
1.5. Challenges of Online Voting …………………………...
Conclusion……………………………………………………… 47-47
References……………………………………………………… 48-48
1. INTRODUCTION
1.1 Overview
The objective of Online voting system is to help the organization in automatingthe whole manual
processing of the existing system.The main objective to develop the system is to make the accurate
& efficient decisions indifferent tasks at different time at different situations. The existing system is
manual somembers of the unit generally face a lot of embarrassing situations many times. Now they need
to automate the whole process so as to make it more easy and accurate.
System should support multi-user environment. System should be fully automated.System should provide
concrete security features like creating users and assigningprivileges to users of the system.
System should be capable to keep track of all the detailed descriptions of the client andthe whole details
of services offered by the client organization.
Various outputs (reports) should be available online any time.System should be able to handle extremely
large volumes of data (i.e. Large databasesupport).
1.2 Objective
The most crucial factor for a system like e-VOTE to be successful is to exhibit a Voting Protocol that can
prevent opportunities for fraud or for sacrificing the voter's privacy.The Voting Protocol that will be
designed and implemented for the e-VOTE system will combine the advantages of existing protocols and
techniques, while at the same time it will aim at eliminating most of the identified deficiencies and
problems. The related attributes that the e-VOTE system will fully support, and against which it will be
extensively tested and validated, are listed below. These attributes can be also considered, according to
the literature, as a set of criteria for a "good" electronic voting system that can easily enjoy the trust and
confidence of the voters and process organizers.
Democracy: The system should be "democratic" in the sense that it will permit only eligible voters to
vote (eligibility) and it will ensure that each eligible voter can vote only once (unreusability).
Privacy: The system should ensure that none of the actors involved in the voting process (organizers,
administrators, voters etc.) can link any ballot (contextually) to the voter who cast it, and that no voter can
prove that he or she voted in a particular way (unintractability).
Integrity: The necessary mechanism should be employed in order to guarantee that no one can duplicate
his or someone else's vote (duplicability) and no one can change someone else's vote (unchangeability)
Accuracy: The system functionality should ensure that no one can falsify or modify the result of the
voting by eliminating a valid vote or counting an invalid vote in the final tally.
Verifiability: The system should allow and support anyone to independently verify that all votes have
been counted correctly.
Convenience: The system should allow and assist voters to cast their votes quickly, in one session, and
with minimal equipment or special skills.
Flexibility: The system should allow a variety of ballot formats and it should be customized to the
Page 1
Efficiency: The election can be held in a timely manner (i.e. all computations during the election are done
in a reasonable amount of time and voters are not required to wait on other voters to complete the
process).
Scalability: The size of the election should not drastically affect performance. In parallel with the
development of the aforementioned e-VOTE functionality and the implementation of the associated
voting protocol, the consortium will take into account all relevant European legal and regulatory issues
that may pose extra requirements or constraints in terms of the functionality, the equipment, or the
security measures. Furthermore, legal issues associated with the use of Internet for electronic voting will
be explored, clarified and incorporated into the system.
Learning curve: As with any new process, online election methods might cause anxiety and trepidation
for some members. You’ll need to invest in a well-planned promotion and education strategy to properly
teach and reassure members about the new election process. This plan will require buy-in from leadership
and must be large enough in scope to reach all members.
Page 2
Not all organizations are a good fit: Online elections are not the best answer for every association, nor
are all association members computer-savvy. Some members may not have easy access to the Internet.
According to the Pew Internet and American Life Project, only 42 percent of Americans ages 65 and
older use the Internet. Also, only 67 percent of people living in rural communities use the Internet
compared to 81 percent of people living in urban areas. T
his means that an association consisting primarily of older members who live in sparsely populated areas
should consider maintaining some form of traditional voting practice. Before investing in an online voting
system, take the time to break down your association’s demographics and tendencies so that you can build
a voting process that best serves the needs of your members.
Expertise required: Building an online voting system requires programming experience and an
understanding of election processes. Often, associations need to look outside the organization to establish
an online voting system either because their staff lacks the necessary expertise or because building such a
system internally would put an unreasonable strain on employee resources. If you use an outside vendor,
your challenge will be to find an election partner as serious about your election as you are
2. PROJECT ANALYSIS
In the present system the is no such application level system provisions in the country to carry out the
voting and procedure as a whole . Also in the present status, there is no such application in use for
automated system for voting according to the voting structure existing in the country. All the step by step
procedures are carried out by the authorized authorities according to the jobs assigned by the ECI. The
fact is all the procedures are carried out manually, starting from the registration process to result
publishing.
The government to do this process manually wastes a lot of time and money. Thus the present system
proves itself to be an inefficient one. The existing system is not web based. The user or person must want
to go to the polling station for casting their votes.
Page 3
The proposed system is more reliable, faster, accurate and easy to handle compared to existing manual
system.
It helps to computerize everything and reducing the errors as compare to manual voting system. The new
implemented voting protocol has two main players: The voter and administrator sections. The
voter(which can be found at home, in a working station, in a special polling station or any other device
have the fuction of performing the Authentication and voting).The administrator performs the function of
voter and candidate registration, authorization and validation of voter, database and counting and the
result.
The main advantages of the new protocol are the following:
Furthermore it is assumed that a trustworthy Administrator is available. Apart from that, the accessibility
to the public in the voting procedure plays a special role, which means that the voting result can be
monitored, although casting of the votes has to be secret as a matter of course.
Accessibility to the public is necessary for all voting stages and is performed by the electoral committee,
but also by any member of the public.
Page 4
3. SYSTEM REQUIREMENTS
Requirement Specification is the part of the project which gives the details about the hardware and
software requirements of our project. It also details the features of the programming language used.
Server Apache To develop application software, we use different types of software. The software for the
development has been selected based on several factors such as:
Support
Cost Effectiveness
Development Speed
Ability to create robust application least time
Stability
Page 5
Advantages of HTML
Many people know from their own experience that it's not easy to install an Apache web server and it gets
harder if you want to add MariaDB, PHP and Perl. The goal of XAMPP is to build an easy to install
distribution for developers to get into the world of Apache. To make it convenient for developers,
XAMPP is configured with all features turned on. In the case of commercial use please take a look at the
product licenses, from the XAMPP point of view commercial use is also free. There are currently
distributions for Windows, Linux, and OS X.
XAMPP is a compilation of free software (comparable to a Linux distribution), it's free of charge and it's
free to copy under the terms of the GNU General Public Licence. But it is only the compilation of
XAMPP that is published under GPL. Please check every single licence of the contained products to get
an overview of what is, and what isn't, allowed. In the case of commercial use please take a look at the
product licences (especially MySQL), from the XAMPP point of view commercial use is also free.
Page 6
[D]. MYSQL
It is the world's most popular open source database. It is a Relational Database Management System
(RDBMS) - data and it's relationships are stored in the form of tables that can be accessed by the use of
MYSQL queries in almost any format that the user wants.
The MySQL server software itself and the client libraries use dual-licensing distribution. They are offered
under GPL version 2, or a proprietary license.
Support can be obtained from the official manual.Free support additionally is available in different IRC
channels and forums. Oracle offers paid support via its MySQL Enterprise products. They differ in the
scope of services and in price. Additionally, a number of third party organisations exist to provide support
and services.
MySQL has received positive reviews, and reviewers noticed it "performs extremely well in the average
case" and that the "developer interfaces are there, and the documentation (not to mention feedback in the
real world via Web sites and the like) is very, very good". It has also been tested to be a "fast, stable and
true multi-user, multi-threaded SQL database server".
MySQL provides our small, medium and large enterprise customers with affordable, open access to their
web data warehouses. MySQL allows us to offer our System Administrator low cost, low maintenance
database solution for applications without sacrificing power, performance or scalability.
Easy to maintain & upgrade, does not have a slew of administrative tasks to put up.
Its table format does not vary between releases
It has cleanly separated table handler modules and can mix access to different type of tables.
It seems to be developed iteratively, and the features are very stable when they ship them.
It is a relational database. Over the past several years, this relational database management systems.
become the most widely accepted way to manage data
It offers benefits such as:
Easy to access data
Flexibility in data modeling
Reduced data storage and redundancy
Independence of physical storage and logical data design
A high level data manipulation language
Page 7
5. SYSTEM DESIGN
System Design’s main aim is to identify the modules that should be in the system, the specifications of
these modules and how they interact with each other to produce the desired results. At the end of system
design all the major data structures, file formats and the major modules in the system and their
specifications are decided.The most creative and challenging phase of the system development process is
design phase, it is a solution, a “how to” approach to the creation of the proposed system Design, the first
step in the development of an engineered product is initiated only after a clear exposition of expected
product functions becomes available. Based on the user requirements and the detailed analysis of a new
system, the new system must be designed. This is the phase of system designing. Normally the design
proceeds in two stages: preliminary or general design, structure or detailed design.
Preliminary or general design: In the preliminary or general design, the features of the new system are
specified. The costs of implementing these features and benefits to be derived are estimated. If the project
is still considered to be feasible, we move to detailed design stage.
Structure or detailed design: In the detailed design stage, computer oriented work begins in the earnest.
At this stage, the design of the system becomes more structured. Structured design is a blue print of a
computer system solution to a given problem having the same components and inter- relationship among
the same components as the original problem. Input, output and processing specifications are drawn up in
detail .In the design stage, the programming language and the platform in which the new system will run
are also decided. There are several tools and techniques used for designing.
Arrow: An arrow identifies the data flow in motion. It is a pipeline through which information is flow
like the rectangle in the flowchart
Circle: A circle stands for process that converts data into information
Page 8
Open End Box: An open ended box represents a data store, data at rest or a temporary repository of
data.
Squares: A square defines a source or destination of system
DFD Level-0
The above diagram is a 0-level DFD that only shows the flow of data between the various and the system.
In online voting system the Administrator is the controller of the system and all the decisions are made by
him. The Administrator can handle the entire voter and their details, voting details etc. and view details of
them and he can update that detail also.
Page 9
Level-1 DFD
The above shown diagram is a 2.1 level Data Flow Diagram for the Online voting system. According to
this DFD. The Administrator can register the voter information. Administrator can allow or denies the
voter. A voter can give vote if all the information filled by him\her are correct.
Page 10
6. FEASIBILITY STUDY
Depending on the results of the initial investigation the survey is now expanded to a more detailed
feasibility study. “FEASIBILITY STUDY” is a test of system proposal according to its workability,
impact of the organization, ability to meet needs and effective use of the resources. It focuses on these
major questions:
1. What are the user’s demonstrable needs and how does a candidate system meet them?
2. What resources are available for given candidate system?
3. What are the likely impacts of the candidate system on the organization?
4. Whether it is worth to solve the problem?
During feasibility analysis for this project, following primary areas of interest are to be considered.
Investigation and generating ideas about a new system does this.
Page 11
A study of resource availability that may affect the ability to achieve an acceptable system.
This evaluation determines whether the technology needed for the proposed system is available or not.
Can the work for the project be done with current equipment existing software technology&
available personal?
Can the system be upgraded if developed?
If new technology is needed then what can be developed?
This is concerned with specifying equipment and software that will successfully satisfy the user
requirement. The technical needs of the system may include:
An important issue for the development of a project is the selection of suitable front-end and back-end.
When we decided to develop the project we went through an extensive study to determine the most
suitable platform that suits the needs of the organization as well as helps in development of the project.
The aspects of our study included the following factors.
Front-end selection:
1. It must have a GUI that assists employees that are not from IT background.
2. Scalability and extensibility.
3. Flexibility.
4. Robustness.
5. According to the organization requirement and the culture.
6. Must provide excellent reporting features with good printing support.
7. Platform independent.
8. Easy to debug and maintain.
9. Event driven programming facility.
10. Front end must support some popular back end like Ms Access.
According to the above stated features we selected PHP as the front-end for developing our project .
Page 12
Back-end Selection:
1. Multiple user support.
2. Efficient data handling.
3. Provide inherent features for security.
4. Efficient data retrieval and maintenance.
5. Stored procedures.
6. Popularity.
7. Operating System compatible.
8. Easy to install.
9. Various drivers must be available.
10. Easy to implant with the Front-end.
According to above stated features we selected MY SQL as the backend. The technical feasibility is
frequently the most difficult area encountered at this stage. It is essential that the process of analysis and
definition be conducted in parallel with an assessment to technical feasibility. It centers on the existing
computer system and to what extent it can support the proposed system.
Economic justification is generally the “Bottom Line” consideration for most systems. Economic
justification includes a broad range of concerns that includes cost benefit analysis. In this we weight the
cost and the benefits associated with the candidate system and if it suits the basic
purpose of the organization i.e. profit making, the project is making to the analysis and design phase.
The financial and the economic questions during the preliminary investigation are verified to estimate the
following:
Page 13
Time evaluation is the most important consideration in the development of project. The time schedule
required for the developed of this project is very important since more development time effect machine
time, cost and cause delay in the development of other systems. A reliable Online voting system can be
developed in the considerable amount of time.
7. TESTING
Types Of Testing
Software testing is a critical element of software quality assurance and represents the ultimate review of
specification, design, and coding. The user tests the developed system and changes are made according to
their needs. The testing phase involves the testing developed system using various kinds of data. System
is the stage of implementation that is aimed at assuring at the system works accurately and efficiently
before live operation commences. Testing is vital to the success of the system.
System testing makes a logical assumption that if all the parts of the system are correct, the goal will be
successfully achieved. The candidate system is subject to a variety of tests such as recover, security and
usability tests. A series of testing is performed for the proposed system before the system is ready for the
user acceptance testing. Implementation ends with formal tests. The test data are very crucial to this
process. They must be realistic and cover extreme conditions are well. Ideally, vary alternative path
through the program should be exercised at least once beyond the test data. The system test must involve
all the elements that compose the system including program validation checking, files, and forms and
triggers procedures.
Testing Strategies Following are few of the testing strategies used for the testing purpose:
Unit testing
Validation testing
Output testing
User acceptance testing
Page 14
User acceptance of a system is the key factory for the success of any system. The system under
consideration is tested for user acceptance by constantly keeping in touch with the perspective system.
Users at time of developing can make changes wherever required. This is done in regards to the following
points:
Page 15
Testing Guidelines
Testing guidelines are hints for the testing team to help them choose tests that will reveal defects in the
system.
• Choose inputs that force the system to generate all error messages;
• Design inputs that cause buffers to overflow;
• Repeat the same input or input series several times;
• Force invalid outputs to be generated;
• Force computation results to be too large or too small.
Involves designing the test cases (inputs and outputs) used to test the system.
The goal of test case design is to create a set of tests that are effective in validation and defect testing.
Design approaches:
• Partition testing;
• Structural testing
Input data and output results often fall into different classes where all members of a class are related.
Each of these classes is an equivalence partition or domain where the program behaves in an equivalent
way for each class member.
Test cases should be chosen from each partition.
Page 16
8. MODULE DESIGN
Administrator Module
User Module
User interface consists of a login name and unique password using which he/she can login into the Online
Voting System. This will be supplied by the administrator to the user. Once the user has logged in, he has
the privilege to view the names of the candidates listed by the administrator, view the results after the
termination date of the election. The user module constitutes only one sub module:
After login the voter enters the voter home page ,which provides the links :
Candidate List
This facilitates the voter to view the candidate names, the constituency name, their symbol and their party
name.
Vote
This provides the voter with a list of candidate with in his/her constituency along with selection option
(radio button) to select the preferred candidate from the list. If the voting date is before termination date,
the vote goes valid else goes invalid.
Page 17
View Results
This provides graphical and user friendly representation of the votes obtained by each candidate. It
includes the percentage of the votes obtained by each candidate. But the result can be viewed only after
the termination date of the election.
Logout
This provides an option for the voter to quit the session ,while in the voter home page.
Administrator interface consists of a login name and unique password using which admin can login into
the Online Voting System. Administrator has the main control of the system. By logging into the page it
can perform the following tasks.
Add Candidate
Here the admin can add the list of candidates in the election. It includes candidates name, address. party
symbol etc. The candidates will be added to the list only after completing the procedures.
Add Voter
Here the voters can be added to the database. The voters have also the privilege to check the voters list
from the homepage. The voters details includes name, address, gender, age, constituency, image etc.
Add Election
Here the election to be conducted is selected. To add an election the constituency should be selected and
termination date of election should be specified.
Add Constituency
The constituency that is going to conduct election should be selected.
Voters List
Here we can view the voters list. Each constituency will be having separate voters list.
Page 18
Candidate List
The list of candidates participating in the election can be seen. It includes the candidates name, party
name and party symbol.
Voting Structure
Here the eligible voters who are permitted to login to the system can utilize the right to vote. Each voter
can register a single vote to a candidate’s favour in his/her constituency. The security measures taken
within the system prevents them from exercising their votes again i.e. the second vote by the same user
goes invalid. The starting and ending dates of the election are specified by the administrator. The user
must have an identity card and he must be in voters list.
Voters Registration
The registration procedure of all the eligible voters .This registration process is done by the administrator.
According to voters database each voter is provided with a unique identification codes which includes
username and password.
The details of the voters include username, password, name, address, gender, constituency, image
etc.With the voter registration, thus producing the voter list with the given information of the voters. The
voter list can be viewed by anyone accessing the webpage. The admin can view the voter list with in his
homepage.
Candidate Registration
The registration of the candidates in each constituency is done by the administrator. The details of the
candidate includes name, address, gender ,his/her constituency, party and image. With the candidate
registration, thus producing the candidate list with the given information of the candidate’s
Page 19
The candidate list can be viewed by admin and the vote within their respective homepages. According to
candidates database (manual) each details of the candidates are stored in database controlled by the
admin including candidates details.
When the voter votes, the number of votes obtained by the selected candidate is incremented by 1.The
result is published only after the voting process is over. It is accessible from the next day after the
termination date. Here we depict the result in the graphical representation according to the percentage of
vote obtained by the candidate. Result can be viewed by everyone who visits into the site without any
authentication problem.
A link to view the result is kept in the index page and both admin and voter can view the result in their
respective homepages. When the user clicks the “RESULT” link, before the termination date of the
election, “Result not Published yet” Message will be displayed. The result comes with their party symbol
on the top of the graph representing the percentage of vote obtained by each candidate.
Page 20
Page 21
Page 22
Page 23
10. CODING
<?php
session_start();
if(isset($_SESSION['admin'])){
header('location: admin/home.php');
}
if(isset($_SESSION['voter'])){
header('location: home.php');
}
?>
<?php include 'includes/header.php'; ?>
<body class="hold-transition login-page">
<div class="login-box">
<div class="login-logo">
<b>Voting System</b>
</div>
<div class="login-box-body">
<p class="login-box-msg">Sign in to start your session</p>
Page 24
</div>
";
unset($_SESSION['error']);
}
?>
</div>
<?php
include 'includes/session.php';
include 'includes/slugify.php';
if(isset($_POST['vote'])){
if(count($_POST) == 1){
$_SESSION['error'][] = 'Please vote atleast one candidate';
}
else{
$_SESSION['post'] = $_POST;
$sql = "SELECT * FROM positions";
$query = $conn->query($sql);
$error = false;
$sql_array = array();
while($row = $query->fetch_assoc()){
$position = slugify($row['description']);
$pos_id = $row['id'];
if(isset($_POST[$position])){
if($row['max_vote'] > 1){
if(count($_POST[$position]) > $row['max_vote']){
$error = true;
$_SESSION['error'][] = 'You can only choose '.$row['max_vote'].' candidates for
'.$row['description'];
}
else{
foreach($_POST[$position] as $key => $values){
$sql_array[] = "INSERT INTO votes (voters_id, candidate_id, position_id) VALUES
('".$voter['id']."', '$values', '$pos_id')";
}
Page 25
else{
$candidate = $_POST[$position];
$sql_array[] = "INSERT INTO votes (voters_id, candidate_id, position_id) VALUES
('".$voter['id']."', '$candidate', '$pos_id')";
}
if(!$error){
foreach($sql_array as $sql_row){
$conn->query($sql_row);
}
unset($_SESSION['post']);
$_SESSION['success'] = 'Ballot Submitted';
}
else{
$_SESSION['error'][] = 'Select candidates to vote first';
}
header('location: home.php');
?>
Page 26
<div class="content-wrapper">
<div class="container">
}
if(isset($_SESSION['success'])){
echo "
<div class='alert alert-success alert-dismissible'>
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
<h4><i class='icon fa fa-check'></i> Success!</h4>
".$_SESSION['success']."
</div>
";
Page 27
unset($_SESSION['success']);
}
?>
<?php
$sql = "SELECT * FROM votes WHERE voters_id = '".$voter['id']."'";
$vquery = $conn->query($sql);
if($vquery->num_rows > 0){
?>
<div class="text-center">
<h3>You have already voted for this election.</h3>
<a href="#view" data-toggle="modal" class="btn btn-flat btn-primary btn-lg">View Ballot</a>
</div>
<?php
}
else{
?>
<!-- Voting Ballot -->
<form method="POST" id="ballotForm" action="submit_ballot.php">
<?php
include 'includes/slugify.php';
$candidate = '';
$sql = "SELECT * FROM positions ORDER BY priority ASC";
$query = $conn->query($sql);
while($row = $query->fetch_assoc()){
$sql = "SELECT * FROM candidates WHERE position_id='".$row['id']."'";
$cquery = $conn->query($sql);
while($crow = $cquery->fetch_assoc()){
$slug = slugify($row['description']);
$checked = '';
if(isset($_SESSION['post'][$slug])){
$value = $_SESSION['post'][$slug];
if(is_array($value)){
foreach($value as $val){
if($val == $crow['id']){
$checked = 'checked';
}
}
}
else{
Page 28
if($value == $crow['id']){
$checked = 'checked';
}
}
}
$input = ($row['max_vote'] > 1) ? '<input type="checkbox" class="flat-red '.$slug.'"
name="'.$slug."[]".'" value="'.$crow['id'].'" '.$checked.'>' : '<input type="radio"
class="flat-red '.$slug.'" name="'.slugify($row['description']).'"
value="'.$crow['id'].'" '.$checked.'>';
$image = (!empty($crow['photo'])) ? 'images/'.$crow['photo'] : 'images/profile.jpg';
$candidate .= '
<li>
'.$input.'<button type="button" class="btn btn-primary btn-sm btn-flat clist platform" data-
platform="'.$crow['platform'].'" data-fullname="'.$crow['firstname'].'
'.$crow['lastname'].'"><i class="fa fa-search"></i> Platform</button><img
src="'.$image.'" height="100px" width="100px" class="clist"><span class="cname
clist">'.$crow['firstname'].' '.$crow['lastname'].'</span>
</li>
';
}
echo '
<div class="row">
<div class="col-xs-12">
<div class="box box-solid" id="'.$row['id'].'">
<div class="box-header with-border">
<h3 class="box-title"><b>'.$row['description'].'</b></h3>
</div>
<div class="box-body">
<p>'.$instruct.'
<span class="pull-right">
<button type="button" class="btn btn-success btn-sm btn-flat reset" data-
desc="'.slugify($row['description']).'"><i class="fa fa-refresh"></i> Reset</button>
</span>
</p>
<div id="candidate_list">
<ul>
'.$candidate.'
</ul>
</div>
</div>
</div>
</div>
</div>
';
Page 29
$candidate = '';
?>
<div class="text-center">
<button type="button" class="btn btn-success btn-flat" id="preview"><i class="fa fa-file-
text"></i> Preview</button>
<button type="submit" class="btn btn-primary btn-flat" name="vote"><i class="fa fa-check-
square-o"></i> Submit</button>
</div>
</form>
<!-- End Voting Ballot -->
<?php
}
?>
</div>
</div>
</section>
</div>
</div>
Page 30
$('#preview').click(function(e){
e.preventDefault();
var form = $('#ballotForm').serialize();
if(form == ''){
$('.message').html('You must vote atleast one candidate');
$('#alert').show();
}
else{
$.ajax({
type: 'POST',
url: 'preview.php',
data: form,
dataType: 'json',
success: function(response){
if(response.error){
var errmsg = '';
var messages = response.message;
for (i in messages) {
errmsg += messages[i];
}
$('.message').html(errmsg);
$('#alert').show();
}
else{
$('#preview_modal').modal('show');
$('#preview_body').html(response.list);
}
}
});
}
});
});
</script>
</body>
</html>
Page 31
<?php
session_start();
include 'includes/conn.php';
if(isset($_POST['login'])){
$voter = $_POST['voter'];
$password = $_POST['password'];
}
else{
$_SESSION['error'] = 'Input voter credentials first';
}
header('location: index.php');
?>
<?php
session_start();
session_destroy();
header('location: index.php');
?>
Page 32
<?php
include 'includes/session.php';
include 'includes/slugify.php';
$output = array('error'=>false,'list'=>'');
while($row = $query->fetch_assoc()){
$position = slugify($row['description']);
$pos_id = $row['id'];
if(isset($_POST[$position])){
if($row['max_vote'] > 1){
if(count($_POST[$position]) > $row['max_vote']){
$output['error'] = true;
$output['message'][] = '<li>You can only choose '.$row['max_vote'].' candidates for
'.$row['description'].'</li>';
}
else{
foreach($_POST[$position] as $key => $values){
$sql = "SELECT * FROM candidates WHERE id = '$values'";
$cmquery = $conn->query($sql);
$cmrow = $cmquery->fetch_assoc();
$output['list'] .= "
<div class='row votelist'>
<span class='col-sm-4'><span class='pull-right'><b>".$row['description']."
:</b></span></span>
<span class='col-sm-8'>".$cmrow['firstname']." ".$cmrow['lastname']."</span>
</div>
";
}
}
else{
$candidate = $_POST[$position];
$sql = "SELECT * FROM candidates WHERE id = '$candidate'";
$csquery = $conn->query($sql);
$csrow = $csquery->fetch_assoc();
$output['list'] .= "
<div class='row votelist'>
<span class='col-sm-4'><span class='pull-right'><b>".$row['description']."
:</b></span></span>
Page 33
echo json_encode($output);
?>
Page 34
unset($_SESSION['error']);
}
if(isset($_SESSION['success'])){
echo "
<div class='alert alert-success alert-dismissible'>
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
<h4><i class='icon fa fa-check'></i> Success!</h4>
".$_SESSION['success']."
</div>
";
unset($_SESSION['success']);
}
?>
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header with-border">
<a href="#addnew" data-toggle="modal" class="btn btn-primary btn-sm btn-flat"><i class="fa
fa-plus"></i> New</a>
</div>
<div class="box-body">
<table id="example1" class="table table-bordered">
<thead>
<th class="hidden"></th>
<th>Position</th>
<th>Photo</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Platform</th>
<th>Tools</th>
</thead>
<tbody>
<?php
$sql = "SELECT *, candidates.id AS canid FROM candidates LEFT JOIN positions ON
positions.id=candidates.position_id ORDER BY positions.priority ASC";
$query = $conn->query($sql);
while($row = $query->fetch_assoc()){
$image = (!empty($row['photo'])) ? '../images/'.$row['photo'] : '../images/profile.jpg';
echo "
<tr>
<td class='hidden'></td>
<td>".$row['description']."</td>
<td>
<img src='".$image."' width='30px' height='30px'>
<a href='#edit_photo' data-toggle='modal' class='pull-right photo' data-
id='".$row['canid']."'><span class='fa fa-edit'></span></a>
</td>
<td>".$row['firstname']."</td>
Page 35
<td>".$row['lastname']."</td>
<td><a href='#platform' data-toggle='modal' class='btn btn-info btn-sm btn-flat platform'
data-id='".$row['canid']."'><i class='fa fa-search'></i> View</a></td>
<td>
<button class='btn btn-success btn-sm edit btn-flat' data-id='".$row['canid']."'><i
class='fa fa-edit'></i> Edit</button>
<button class='btn btn-danger btn-sm delete btn-flat' data-id='".$row['canid']."'><i
class='fa fa-trash'></i> Delete</button>
</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
</div>
Page 36
});
function getRow(id){
$.ajax({
type: 'POST',
url: 'candidates_row.php',
data: {id:id},
dataType: 'json',
success: function(response){
$('.id').val(response.canid);
$('#edit_firstname').val(response.firstname);
$('#edit_lastname').val(response.lastname);
$('#posselect').val(response.position_id).html(response.description);
$('#edit_platform').val(response.platform);
$('.fullname').html(response.firstname+' '+response.lastname);
$('#desc').html(response.platform);
}
});
}
</script>
</body>
</html>
Page 37
<li class="active">Positions</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<?php
if(isset($_SESSION['error'])){
echo "
<div class='alert alert-danger alert-dismissible'>
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
<h4><i class='icon fa fa-warning'></i> Error!</h4>
".$_SESSION['error']."
</div>
";
unset($_SESSION['error']);
}
if(isset($_SESSION['success'])){
echo "
<div class='alert alert-success alert-dismissible'>
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
<h4><i class='icon fa fa-check'></i> Success!</h4>
".$_SESSION['success']."
</div>
";
unset($_SESSION['success']);
}
?>
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header with-border">
<a href="#addnew" data-toggle="modal" class="btn btn-primary btn-sm btn-flat"><i class="fa
fa-plus"></i> New</a>
</div>
<div class="box-body">
<table id="example1" class="table table-bordered">
<thead>
<th class="hidden"></th>
<th>Description</th>
<th>Maximum Vote</th>
<th>Tools</th>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM positions ORDER BY priority ASC";
$query = $conn->query($sql);
while($row = $query->fetch_assoc()){
echo "
Page 38
<tr>
<td class='hidden'></td>
<td>".$row['description']."</td>
<td>".$row['max_vote']."</td>
<td>
<button class='btn btn-success btn-sm edit btn-flat' data-id='".$row['id']."'><i class='fa
fa-edit'></i> Edit</button>
<button class='btn btn-danger btn-sm delete btn-flat' data-id='".$row['id']."'><i class='fa
fa-trash'></i> Delete</button>
</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
</div>
});
function getRow(id){
$.ajax({
type: 'POST',
Page 39
url: 'positions_row.php',
data: {id:id},
dataType: 'json',
success: function(response){
$('.id').val(response.id);
$('#edit_description').val(response.description);
$('#edit_max_vote').val(response.max_vote);
$('.description').html(response.description);
}
});
}
</script>
</body>
</html>
Page 40
".$_SESSION['error']."
</div>
";
unset($_SESSION['error']);
}
if(isset($_SESSION['success'])){
echo "
<div class='alert alert-success alert-dismissible'>
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
<h4><i class='icon fa fa-check'></i> Success!</h4>
".$_SESSION['success']."
</div>
";
unset($_SESSION['success']);
}
?>
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header with-border">
<a href="#addnew" data-toggle="modal" class="btn btn-primary btn-sm btn-flat"><i class="fa
fa-plus"></i> New</a>
</div>
<div class="box-body">
<table id="example1" class="table table-bordered">
<thead>
<th>Lastname</th>
<th>Firstname</th>
<th>Photo</th>
<th>Voters ID</th>
<th>Tools</th>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM voters";
$query = $conn->query($sql);
while($row = $query->fetch_assoc()){
$image = (!empty($row['photo'])) ? '../images/'.$row['photo'] : '../images/profile.jpg';
echo "
<tr>
<td>".$row['lastname']."</td>
<td>".$row['firstname']."</td>
<td>
<img src='".$image."' width='30px' height='30px'>
<a href='#edit_photo' data-toggle='modal' class='pull-right photo' data-
id='".$row['id']."'><span class='fa fa-edit'></span></a>
</td>
<td>".$row['voters_id']."</td>
Page 41
<td>
<button class='btn btn-success btn-sm edit btn-flat' data-id='".$row['id']."'><i class='fa
fa-edit'></i> Edit</button>
<button class='btn btn-danger btn-sm delete btn-flat' data-id='".$row['id']."'><i class='fa
fa-trash'></i> Delete</button>
</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
</div>
});
function getRow(id){
Page 42
$.ajax({
type: 'POST',
url: 'voters_row.php',
data: {id:id},
dataType: 'json',
success: function(response){
$('.id').val(response.id);
$('#edit_firstname').val(response.firstname);
$('#edit_lastname').val(response.lastname);
$('#edit_password').val(response.password);
$('.fullname').html(response.firstname+' '+response.lastname);
}
});
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Voting System using PHP</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
name="viewport">
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
<!-- iCheck for checkboxes and radio inputs -->
<link rel="stylesheet" href="plugins/iCheck/all.css">
<!-- DataTables -->
<link rel="stylesheet" href="bower_components/datatables.net-
bs/css/dataTables.bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
Page 43
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
.mt20{
margin-top: 20px;
}
.title{
font-size: 50px;
}
#candidate_list{
margin-top:20px;
}
#candidate_list ul{
list-style-type:none;
}
#candidate_list ul li{
margin:0 30px 30px 0;
vertical-align:top
}
.clist{
margin-left: 20px;
}
.cname{
font-size: 25px;
}
.votelist{
font-size: 17px;
}
</style>
</head>
Page 44
<footer class="main-footer">
<div class="container">
<div class="pull-right hidden-xs">
<b>All rights reserved</b>
</div>
<strong>Copyright © 2023 <a href="">RakeshGehlot</a></strong>
</div>
<!-- /.container -->
</footer>
<header class="main-header">
<nav class="navbar navbar-static-top">
<div class="container">
<div class="navbar-header">
<a href="#" class="navbar-brand"><b>Voting</b>System</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-
target="#navbar-collapse">
<i class="fa fa-bars"></i>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse pull-left" id="navbar-collapse">
<ul class="nav navbar-nav">
<?php
if(isset($_SESSION['student'])){
echo "
<li><a href='index.php'>HOME</a></li>
<li><a href='transaction.php'>TRANSACTION</a></li>
";
}
?>
</ul>
</div>
<!-- /.navbar-collapse -->
<!-- Navbar Right Menu -->
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<li class="user user-menu">
<a href="">
Page 45
<?php
include 'includes/conn.php';
session_start();
if(isset($_SESSION['voter'])){
$sql = "SELECT * FROM voters WHERE id = '".$_SESSION['voter']."'";
$query = $conn->query($sql);
$voter = $query->fetch_assoc();
}
else{
header('location: index.php');
exit();
}
?>
Page 46
CONCLUSION
This Online Voting system will manage the Voter’s information by which voter can login and use his
voting rights. The system will incorporate all features of Voting system. Its provide the tools for
maintaining voter’s vote to every party and it count total no. of votes of every party. There is a
DATABASE which is maintained by the ELECTION COMMISION OF INDIA in which all the names
of voter with complete information is stored.
In this user who is above 18 year’s register his/her information on the database and when he/she want to
vote he/she has to login by his id and password and can vote to any party only single time.
Voting detail store in database and the result is displayed by calculation. By online voting system
percentage of voting is increases. It decreases the cost and time of voting process. It is very easy to use
and It is vary less time consuming. It is very easy to debug.
In this user who is above 18years’s register his/her information on the database and when he/she want to
vote he/she has to login by his id and password and can vote to any party only single time. Voting detail
store in database and the result is displayed by calculation. By online voting system percentage of voting
is increases.
It decreases the cost and time of voting process. It is very easy to use and it is very less time consuming.
It is very easy to debug. The traditional method of manual voting system has few drawbacks. This
method is obviously not efficient as it wastes the voter’s energy and quite slow in term of completion.
This smart system involves the voter’s can cast their vote easily, and can be implemented to the entire
India
Page 47
REFERENCES :-
https://en.wikipedia.org/wiki/Electronic_voting
https://www.w3schools.com/MySQL/default.asp
https://www.apachefriends.org/
https://www.geeksforgeeks.org/election-system-in-india/
https://bootsnipp.com/tags/login
Page 48