Project Report: On Online Voting Management System Submitted To Dept. of Computer, LNMI

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 201

PROJECT REPORT

ON ONLINE VOTING MANAGEMENT


SYSTEM
Submitted to Dept. Of Computer, LNMI

IN PARTIAL FULFILLMENT OF THE


REQUIREMENT OF THE DEGREE AWARD IN
Bachelor of Computer Application (B.C.A)

L.N Mishra Institute of Economic Development & Social


Change Jawaharlal Nehru Marg, Patna-800001, Bihar, Patna

Under The Guidance Of: Submitted by:


Mr. SANJAY KUMAR UTSAV ANAND
PROF. LNMI ROLL NO. - 20662
B.C.A(2020-23)
SESSION: 2020-23
Contents
CHAPTER - 1
o Introduction of the Project
o Objective of the Project
o Features of the Project
o Advantages of the Project

CHAPTER - 2
o Programming Languages Used
 PHP
 HTML
 CSS
 JavaScript
 MySQL (Database)

o Tools and Platforms Used


 Software
 Hardware

CHAPTER – 3

Data Flow Diagram (DFD)

o What is DFD?
o DFD Notations
o Levels of DFD
o Information Sharing and Complaint Registration
Website DFD

CHAPTER – 4

o Entity-Relationship Diagram
o Gantt Chart

CHAPTER – 5

Web Development Life Cycle

o Planning
o Analysis
o Design and Development
o Testing
o Implementation
o Maintenance

CHAPTER – 6

Coding the Website

CHAPTER – 7

Operational Guide with Snapshots

CHAPTER - 8

o Conclusion
o References and Bibliography
CHAPTER - 1

o Introduction of the Project


o Objective of the Project
o Features of the Project
o Advantages of the Project
Introduction of the Project
In recent times, technological advancements have
revolutionized many aspects of our lives. The way we
communicate, work, and entertain ourselves have all been
impacted by these developments. One significant area that
has experienced tremendous growth is the electoral process.

With the emergence of online voting systems, the traditional


approach to voting has undergone a transformation.
Therefore, the project I have developed is an Online Voting
Management System, which is an important step towards
enhancing the democratic process by making voting more
accessible, efficient, and secure
Traditionally, voting has been conducted in person, which has
posed many challenges such as long queues, lack of
accessibility for people with disabilities, and potential
security breaches. With the advancement of technology, the
concept of online voting has emerged, which offers a
convenient and secure alternative to in-person voting.
There are several problems associated with traditional voting
systems, which have been addressed by the development of
online voting systems. Some of the common problems in
traditional voting systems are:
In-person voting is time-consuming and often involves long
queues, which can discourage some people from voting.
Traditional voting systems may not be accessible to people
with disabilities, such as those who are visually impaired or
have mobility issues.
Traditional voting systems can be susceptible to human
errors, such as miscounting of votes or errors in data entry.
There is a potential for fraud or manipulation in traditional
voting systems, such as ballot stuffing or tampering with
ballot boxes.
Traditional voting systems may be affected by logistical
challenges such as transportation issues, natural disasters, or
unexpected emergencies, which can disrupt the voting
process.
Traditional voting systems may not be able to accommodate
a large number of voters, which can result in long waiting
times and congestion at polling stations.
Overall, these problems can result in a lack of trust in the
democratic process and a low turnout of voters. Online
voting systems can address many of these issues by providing
a convenient, accessible, and secure platform for voters to
cast their votes.
An online voting system is a web-based application that
allows voters to cast their votes electronically through the
internet. This system has been gaining popularity in recent
years because of its numerous advantages over the
traditional paper-based voting system.
Online voting is important in India because it can increase
voter turnout, improve accessibility, and reduce the costs
associated with traditional voting methods. Here are some
data points that support the importance of online voting in
India:
1.Low voter turnout
Despite being the world's largest democracy, India has
consistently had low voter turnout rates in its elections. For
example, in the 2019 Lok Sabha elections, the voter turnout
was only 67.11%, which was a slight improvement from the
2014 elections (66.40%). Online voting can provide a more
convenient and accessible option for voters who are unable
to travel to polling booths, potentially increasing voter
turnout.
2.Geographical barriers
India's vast geographical size and diverse population can
pose challenges for traditional voting methods, particularly in
remote and rural areas. Online voting can provide a more
accessible option for voters who may face challenges in
accessing polling stations due to distance, transportation, or
other barriers.
3.Cost savings
Traditional voting methods can be expensive due to the
costs of printing ballots, staffing polling stations, and
transporting election materials. Online voting can reduce
these costs, potentially resulting in significant cost savings for
the government.
4.Technology adoption
As we know that the
Overall, these data points demonstrate the potential benefits
of online voting in India, including increased voter turnout,
improved accessibility, and cost savings. While there are
challenges to implementing online voting, such as ensuring
the security and authenticity of votes, it is clear that online
voting has the potential to transform the electoral process in
India and contribute to a more democratic and inclusive
society. becoming a technology-driven society, with
increasing numbers of citizens using smartphones and other
digital devices. Online voting can tap into this trend and
provide a more modern and convenient way for citizens to
participate in the electoral process.

In this project, we aim to develop an online voting system for


use in the democratic process. The system will be designed to
provide a secure, transparent, and user-friendly platform for
voters to cast their votes remotely. Our focus is to build an
application that is accessible to all voters, regardless of their
technical ability or level of education.
The purpose of this project is to demonstrate the feasibility
and effectiveness of an online voting system as an alternative
to traditional paper-based voting. We believe that this
project will contribute significantly to the advancement of
the electoral process in the country in future. The system will
be designed to meet the highest standards of security and
transparency to ensure the integrity of the electoral process.
In summary, Online Voting Management System is designed
to provide a platform for voters to cast their votes from any
location, at any time, using a secure online interface. The
system is also built with advanced security measures to
ensure the authenticity and confidentiality of votes.
Objective of the Project
The objective of this project on an online voting management
system is to develop a secure and efficient platform that
enables voters to cast their votes from any location, at any
time, using a secure online interface. The project aims to
address the limitations of traditional in-person voting
systems by providing a more accessible, convenient, and
secure method of voting.
The specific objectives of the project are as follows:

1.Design and develop a user-friendly interface:


The system should have a simple and intuitive interface that
enables voters to register easily and cast their votes without
any difficulties. The interface should also provide real-time
feedback to voters, such as confirmation of vote submission
and preview to submit vote.

2.Implement advanced security measures


The online voting system must be highly secure to prevent
unauthorized access or manipulation of the voting data.
Measures such as multi-factor authentication, data
encryption, and regular security audits should be
implemented to ensure the confidentiality and integrity of
the voting process.
3.Provide various reports and analytics
The system should generate various reports and analytics
that provide insights into voting patterns and trends. This
information can be used to identify areas for improvement
and to ensure that the voting process is fair and transparent.

4.Develop a scalable and reliable system


The online voting system should be scalable to
accommodate a large number of voters and reliable enough
to handle high volumes of traffic. The system should be
designed to handle peak loads and should have appropriate
failover mechanisms in place to ensure uninterrupted
service.

5.Ensure compliance with legal and regulatory requirements


The online voting system should comply with all legal and
regulatory requirements related to online voting systems.
These requirements may include data protection regulations,
accessibility requirements, and election laws.

6.Evaluate the effectiveness and usability of the system


User testing and feedback should be used to evaluate the
effectiveness and usability of the system. The system should
be designed to be user-friendly and accessible to voters with
different levels of technical expertise.
Overall, these objectives aim to develop an online voting
management system that is efficient, secure, and user-
friendly. By meeting these objectives, the system will
contribute to the democratization of the voting process,
enhance accessibility and inclusivity, and promote
transparency and trust in the electoral process.
Features of the Project
With our website, you can cast your vote from anywhere,
anytime, and on any device. Our user-friendly interface
ensures that the voting process is easy and straightforward.
But that's not all, our website also offers a comprehensive
dashboard on the admin side that displays all the details
related to voting.
Admin
Dashboard:
Our admin dashboard is the nerve center of our online voting
website. It provides a complete overview of the voting
process, including the total number of voters, the number of
votes cast, and the votes' distribution.

Votes:
The Votes page displays all the votes given by the voters to
the respective candidates. It makes the voting process
transparent and accountable.

Voters Page:
The Voters page allows the admin to modify the voters'
details, such as name.This helps to keep the voter database
up-to-date and accurate.
Position and Candidates Page:
The Position and Candidates pages allow the admin to modify
all the necessary details related to the candidates, such as
their name, position, and photo. The admin can also modify
the ballot position and title of the voting page, making it
more customizable and flexible.

User Interface
On the user side, our website offers a user-friendly interface
that allows the voter to cast their vote and preview their
choices before submitting them. This helps to eliminate
errors and ensures that the voting process is smooth and
efficient.

In conclusion, our online voting website offers a


revolutionary way to cast your vote. It is easy to use,
customizable, and ensures transparency and accountability in
the voting process. So, what are you waiting for? Cast your
vote today on our online voting website!
Advantages of the Project
Convenience: Online voting management systems provide
convenience to both the voters and the administrators.
Voters can cast their vote from the comfort of their home,
while administrators can manage the entire voting process
from a single platform.

Accessibility: Online voting systems provide access to a larger


number of voters, including those who may have difficulty
reaching a polling station. Voters can access the voting
platform from anywhere, as long as they have an internet
connection.

Accuracy: Online voting systems use advanced algorithms to


ensure that each vote is accurately recorded and counted.
This reduces the chances of errors and fraud, which can be
common in traditional voting methods.

Speed: Online voting systems allow for faster vote counting


and result declaration, as compared to traditional voting
methods. This can save time and resources for the
administrators.

Transparency: Online voting systems can provide a


transparent and tamper-proof record of each vote, ensuring
that the results of the election are fair and accurate. This can
help build trust in the voting process.
Cost-effective: Online voting systems can be cost-effective, as
they can eliminate the need for physical polling stations and
reduce the administrative costs associated with traditional
voting methods.

Security: Online voting systems can use advanced encryption


and authentication techniques to ensure that the voting
process is secure and free from any unauthorized access.

Flexibility: Online voting systems can be customized to meet


the specific needs of an election, including the number of
candidates, the number of voters, and the voting rules.

Environmental impact: Online voting systems can reduce the


environmental impact of traditional voting methods, as they
eliminate the need for paper ballots and reduce the carbon
footprint associated with physical polling stations.

Scalability: Online voting systems can scale easily, allowing


them to accommodate a large number of voters and multiple
elections simultaneously. This can be particularly useful for
countries with large populations and frequent elections.
CHAPTER - 2

o Programming Languages Used


 PHP
 HTML
 CSS
 JavaScript
 MySQL (Database)

o Tools and Platform Used


 Software
 Hardware
PHP
PHP (Hypertext Preprocessor) is a server-side scripting
language used for creating dynamic web pages and web
applications. Here are some key features of PHP:
1. Syntax
PHP syntax is similar to that of C and Java, making it easy for
programmers who are familiar with those languages to learn
PHP.

Fig. PHP Syntax


2. Open source
PHP is open source, meaning it is freely available and can be
used by anyone.
3. Platform independence
PHP code can run on various platforms, including Windows,
Linux, and macOS.
4. Easy integration
PHP can be easily integrated with HTML, CSS, and other web
technologies, making it a popular choice for web
development.

5. Database support
PHP provides support for various databases such as MySQL,
Oracle, and PostgreSQL.
6. Security
PHP provides various built-in functions for security, such as
protection against SQL injection attacks.
7. Large community
PHP has a large community of developers who contribute to
its development and provide support through forums and
user groups.
Overall, PHP is a powerful and flexible language that is widely
used in web development.
HTML
HTML (Hypertext Markup Language) is a markup language is
most widely used language on Web to develop web pages.
Here are some key features of HTML:
1. Structure
HTML provides a structure for web pages, allowing
developers to create headings, paragraphs, lists, and other
elements.
2. Tags
HTML uses tags to indicate the beginning and end of
elements on a web page. For example, the <p> tag is used to
indicate the beginning of a paragraph.
3. Attributes
HTML tags can also have attributes, which provide additional
information about an element. For example, the <img> tag
has an attribute called src, which indicates the URL of the
image to be displayed.
4. Accessibility
HTML provides features for making web pages accessible to
users with disabilities, such as using alternative text for
images and providing captions for videos.
5. Compatibility
HTML is supported by all modern web browsers and can be
used with other web technologies such as CSS and JavaScript.

Here's an example of the basic syntax of HTML:


Fig. HTML sample code
In this example, the <!DOCTYPE html> declaration specifies
that the document is an HTML5 document. The <html> tag
indicates the beginning of the HTML document, and the
<head> tag contains metadata about the document, such as
the title of the web page. The <body> tag contains the visible
content of the web page, including headings (<h1>),
paragraphs (<p>), and other elements.
CSS
CSS (Cascading Style Sheets) is a style sheet language used
for describing the presentation of web pages. Here are some
key features of CSS:
1. Styling
CSS is used to apply styles to HTML elements, such as setting
the font size, color, and background of a web page.
2. Selectors
CSS uses selectors to target specific HTML elements on a web
page. For example, the h1 selector targets all the h1 headings
on a web page.
3. Cascade
CSS uses a cascade to determine which styles should be
applied to an element when multiple styles are defined.
Styles with higher specificity or that come later in the
stylesheet will override earlier styles.
4. Inheritance
CSS also supports inheritance, where styles defined for a
parent element will be inherited by its child elements, unless
overridden by a more specific style.
5. Compatibility
CSS is supported by all modern web browsers and can be
used with other web technologies such as HTML and
JavaScript.

Here's an example of the basic syntax of CSS:

Fig. CSS sample code


In this example, the h1 selector targets all the h1 headings on
a web page. The styles defined within the curly braces apply
to those h1 headings. The font-size property sets the font
size to 24px, and the color property sets the color to red.

CSS can be added to HTML documents in 3 ways:


• Inline - by using the style attribute inside HTML
elements
• Internal - by using a <style> element in the <head>
section
• External - by using a <link> element to link to an
external CSS file

JavaScript
JavaScript is a programming language used to create
interactive and dynamic web pages. Here are some key
features of JavaScript:
1. Interaction
JavaScript is used to add interactivity to web pages, such as
responding to user events like clicks or keypresses.
2. Variables and data types
JavaScript supports variables, which can hold different types
of data, such as numbers, strings, and booleans.
3. Control flow
JavaScript supports control flow statements, such as if-else
statements and loops, to control the order in which code is
executed.
4. Functions
JavaScript supports functions, which are reusable blocks of
code that can be called multiple times.
5. Compatibility
JavaScript is supported by all modern web browsers and can
be used with other web technologies such as HTML and CSS.

Here's an example of the basic syntax of JavaScript:

Fig. JavaScript Sample code


In this example, the var keyword is used to declare a variable
called message, which is assigned the value "Hello, World!".
The alert function is then used to display the value of
message in a pop-up dialog box.

MySQL (Used as a Database)


MySQL is a popular open-source relational database
management system. Here are some key features of MySQL:
1. Relational database
MySQL is a relational database, which means that data is
organized into tables with columns and rows.
2. SQL
MySQL uses Structured Query Language (SQL) to manage and
manipulate data within tables.
3. Scalability
MySQL can handle large amounts of data and can be used in
applications with high levels of traffic.
4. Security
MySQL includes built-in security features, such as user
authentication and access control.
5. Compatibility
MySQL is supported by many programming languages and
can be used with a wide range of web technologies.

Tools and Platform used


Software:
Component Specification
Operating System Windows 11
Application Server XAMPP
Technologies Used HTML, CSS, PHP, MySQL
Database MySQL
Designing Bootstrap
IDE Visual Studio Code (VS Code)

Hardware:
Component Specification
Processor Ryzen-5
RAM 8 GB
SSD 512 GB

CHAPTER – 3

Data Flow Diagram (DFD)

o What is DFD?
o DFD Notations
o Levels of DFD
o Information Sharing and Complaint Registration
Website DFD
What is DFD?

Data Flow Diagram (DFD) is a graphical representation of a


system or process, illustrating the flow of data between
different components or processes. It is used to model the
flow of data in a system, starting from the inputs and ending
with the outputs.

The components of a DFD include:

Processes: Represent the activities or tasks that transform


data from one form to another.

Data Flows: Represent the movement of data between


processes, entities, and data stores.

Data Stores: Represent the places where data is stored, such


as databases or files.

External Entities: Represent the sources or destinations of


data outside the system being modeled.

DFDs are useful in software engineering, system analysis,


and business process modeling as they help in
understanding and visualizing how data moves through a
system, which in turn can aid in identifying areas for
improvement or optimization.
Data Flow Diagram Notations
Following are the notations of the data flow diagram that
are used to represent source, destination, storage and flow
of data
.
Data Flow Diagram Levels
In Software engineering, DFD (data flow diagram) can be
drawn to represent the system of different levels of

abstraction. Higher-level DFDs are partitioned into low


levels-hacking more information and functional elements.
Levels in DFD are numbered 0, 1, 2 or beyond. Here, we will
see mainly 3 levels in the data flow diagram, which are: 0-
level DFD, 1-level DFD and 2-level DFD. 
0-level DFD: 
It is also known as a context diagram. It’s designed to be an
abstraction view, showing the system as a single process
with its relationship to external entities. It represents the
entire system as a single bubble with input and output data
indicated by incoming/outgoing arrows. 

1-level DFD: 
In 1-level DFD, the context diagram is decomposed into
multiple bubbles/processes. In this level, we highlight the
main functions of the system and breakdown the high-level
process of 0-level DFD into subprocesses. 

2-level DFD: 
2-level DFD goes one step deeper into parts of 1-level DFD.
It can be used to plan or record the specific/necessary detail
about the system’s functioning. 
CHAPTER – 4

o Entity-Relationship Diagram
o Gantt Chart

Er Diagram

ER Diagram stands for Entity Relationship Diagram, also


known as ERD is a diagram that displays the relationship of
entity sets stored in a database. An ER diagram (Entity-
Relationship diagram) is a graphical representation of
entities and their relationships to each other in a database.
The components of an ER diagram are:

Entities: An entity is a real-world object or concept that has


a unique identity, such as a customer or an order.

Attributes: An attribute is a characteristic or property of an


entity, such as a customer's name or address.

Relationships: A relationship is an association between two


or more entities, such as a customer placing an order.

Cardinality: Cardinality is the number of occurrences of an


entity in a relationship, such as a customer placing multiple
orders.

Weak entities: Weak entities are entities that do not have a


unique identity of their own and are dependent on another
entity.
Gantt Chart

A Gantt chart, commonly used in project management, is one


of the most popular and useful ways of showing activities
(tasks or events) displayed against time. On the left of the
chart is a list of the activities and along the top is a suitable
time scale. Each activity is represented by a bar; the position
and length of the bar reflects the start date, duration and end
date of the activity.
Weeks → 01 02 03 04 05 06 07 08
Project Phases

Planning
Analysis
Design &
Development
Testing
Implementation
Gantt chart for an information sharing and complaint
registration website:

CHAPTER – 5

Web Development Life Cycle


o Planning
o Analysis
o Design and Development
o Testing
o Implementation
o Maintenance

Web Development Life Cycle

Planning: The first stage of the web development life cycle is


planning. In this stage, you will define the scope of the
project, identify the requirements, and set the project
timeline and budget. You will also create a project plan,
which includes tasks, timelines, and responsibilities.

Analysis: In this stage, you will analyze the requirements


identified in the planning stage. You will work with
stakeholders to identify the features and functionalities
required for the online voting system. You will also identify
any potential risks and constraints that may affect the
project.

Design: In the design stage, you will create a design for the
online voting system. You will develop a user interface
design, database schema, and system architecture. You will
also create wireframes and prototypes to help stakeholders
visualize the final product.

Development: In the development stage, you will begin


coding the online voting system. You will use the
technologies identified in the design stage to build the
system. You will also create test cases to ensure the system is
functioning as expected.
Testing: In the testing stage, you will conduct functional,
performance, and security testing. You will test the system
against the requirements identified in the analysis stage. You
will also conduct user acceptance testing to ensure the
system meets the needs of the end-users.

Deployment: In the deployment stage, you will deploy the


online voting system to a production environment. You will
also train end-users on how to use the system.
Maintenance: In the maintenance stage, you will maintain
and support the online voting system. You will also make
updates and enhancements to the system based on feedback
from end-users.
Planning
When planning for a website that tells about electricity in the
form of audio, there are a few key considerations to keep in
mind. Here are some steps to follow in the planning phase:
1. Define the website's purpose
What is the main goal of the website? Is it to educate people
about electricity in general or about a specific aspect of it? Is
it to promote energy conservation or renewable energy?
Clearly defining the website's purpose will help guide the rest
of the planning process.
2. Identify the target audience
Who is the website's intended audience? Is it for students,
educators, industry professionals, or the general public?
Knowing the target audience will help determine the
appropriate content and tone of the website.
3. Choose the audio format
Since the website will focus on audio content, you need to
determine the format of the audio files. Will the audio be in
the form of podcasts, interviews, lectures, or sound bites?
You can also mix different formats to create a more engaging
and varied experience for the audience.
4. Plan the website structure
Once you have a clear idea of the website's purpose,
audience, and audio format, you can start planning the
website's structure. Decide on the number of pages, the
hierarchy of information, and how the audio content will be
organized and presented.

5. Create a content plan


With the website structure in mind, you can start creating a
content plan. This involves deciding on the topics to cover,
creating outlines for each audio piece, and drafting scripts.
You can also plan for supplementary content such as images,
graphics, and text transcripts.
6. Consider accessibility
As mentioned earlier, it's important to consider accessibility
when creating a website that relies heavily on audio content.
Plan for alternative text and captions for audio files so that
people with disabilities can also access the content.
7. Set up analytics and feedback mechanisms
Finally, set up analytics tools and feedback mechanisms to
track the website's performance and gather feedback from
users. This will help you understand how people are
interacting with the website and make improvements as
needed.
By following these steps, you can create a detailed plan for a
website that tells about electricity in the form of audio.
Analysis
Analyzing a website is important to identify areas for
improvement and determine the website's effectiveness in
achieving its goals. Here are some aspects to consider when
analyzing such a website:
1. Audio quality
Analyze the quality of the audio files by listening to them
and identifying any issues such as distortion, background
noise, or low volume. Consider using analytics tools to track
how users are interacting with the audio content, such as
how long they listen to each file or if they share the content
with others.
2. Accessibility
Analyze the website's accessibility by testing it with screen
readers and other assistive technologies to ensure that it is
accessible to people with disabilities. Consider adding
transcripts or captions to the audio files to make them more
accessible to all users.
By following these steps, you can analyze a website.
Design & Development
The website should be designed with the simple mindset
ensuring people of any field can operate it. Web design is an
umbrella term that describes the process of creating a
website. Like the name suggests, it involves two major skill
sets- web design and web development. Web design
determines the look and feel of the website, while web
development determines how it functions.
Testing
When testing a website that tells about electricity in the form
of audio, there are several key areas to focus on. Here are
some aspects to consider during the testing phase:
1. Audio Quality
Test the quality of the audio files to ensure that they are
clear, audible and that there are no distortions. You can
listen to the audio files through various devices and internet
connections to ensure that the audio remains high quality.
2. Compatibility
Test the website on different browsers and devices to ensure
that it works seamlessly across all platforms. Check that the
audio plays on all devices, including desktop, tablet, and
mobile.
3. Accessibility
Ensure that the website is accessible to people with
disabilities by providing captions or transcripts for the audio
content. Test the website using screen readers to ensure that
people with visual impairments can access the content.
4. User Experience
Test the user experience by navigating the website and
listening to the audio content. Check that the website is easy
to use, the navigation is intuitive, and the audio files are
easily accessible.
5. Speed
Test the website's loading speed to ensure that it is
optimized for performance. If the website takes too long to
load, users may become frustrated and leave the website.
6. Security
Test the website's security by performing penetration tests to
identify vulnerabilities that could lead to data breaches.
Ensure that user data is protected and that the website
follows industry-standard security protocols.
7. Functionality
Test the website's functionality by performing various tests
such as form submissions, download functionality, and sign-
up processes. Ensure that all website features and
functionalities are working correctly.
By testing for these aspects, you can ensure that the website
is functioning correctly, providing a good user experience,
and accessible to all users, including those with disabilities.
This will help to ensure that the website meets the needs of
its intended audience and achieves its goals.
Implementation
To implement a website, you can follow these steps:
1. Choose a web development platform
Choose a web development platform that meets your needs
and allows for easy implementation of audio files.
2. Set up hosting and domain
Set up hosting and domain for your website. Choose a
hosting provider that provides reliable uptime and fast load
times to ensure that your audio files load quickly.
3. Install necessary software and tools
Install necessary software and tools, such as a content
management system, audio player, and SEO plugins.
4. Create website content
Create content for your website, including audio files and
transcripts or captions for accessibility. Optimize your
content for SEO by including relevant keywords, meta
descriptions, and tags.
5. Launch website
Launch your website, and promote it through various
channels such as social media, email marketing, and paid
advertising.
By following these steps, you can implement a website,
providing an engaging and informative experience for the
users.

Maintenance
Maintaining a website is essential to keep it up-to-date,
improve user experience, and ensure that it remains relevant
to its audience. Here are some steps involved in maintaining
such a website:
1. Regularly update content
Regularly update the website with new audio content to
keep it fresh and relevant. This can include interviews, news
updates, and educational materials.
2. Monitor website performance
Use website analytics tools to monitor website traffic, user
engagement, and conversion rates. This will help you identify
areas for improvement and make data-driven decisions to
improve the website's performance.
3. Optimize website for SEO
Continuously optimize the website for search engines by
updating keywords, meta tags, and descriptions. This will
improve the website's visibility and increase organic traffic.
4. Test website functionality
Test the website's functionality regularly to ensure that all
features are working correctly. This can include audio player,
search function, and other interactive features.
5. Check for broken links
Check for broken links on the website and fix them promptly
to improve user experience and prevent negative SEO
impact.

6. Respond to user feedback


Respond to user feedback promptly, whether it is positive or
negative, to improve user experience and address any issues.
7. Keep website secure
Regularly update website security software and implement
necessary security measures to prevent hacking attempts and
protect user data.
8. Backup website regularly
Backup the website regularly to prevent data loss in case of
website crashes or other technical issues.
By following these steps, you can ensure that the website
remains relevant, engaging, and accessible to its audience,
providing an excellent user experience and meeting its goals
effectively.
CHAPTER – 6

Coding the Website


C:\xampp\htdocs\music_website\app\pages
Admin->includes
 ballot_modal.php

<!-- Platform -->


<div class="modal fade" id="platform">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><b><span
class="candidate"></b></h4>
</div>
<div class="modal-body">
<p id="plat_view"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
</div>
</div>
</div>
</div>
 candidates_mpdal.php

<!-- Description -->


<div class="modal fade" id="platform">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><b><span
class="fullname"></span></b></h4>
</div>
<div class="modal-body">
<p id="desc"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
</div>
</div>
</div>
</div>

<!-- Add -->


<div class="modal fade" id="addnew">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><b>Add New
Candidate</b></h4>
</div>
<div class="modal-body">
<form class="form-horizontal" method="POST"
action="candidates_add.php" enctype="multipart/form-
data">
<div class="form-group">
<label for="firstname" class="col-sm-3
control-label">Firstname</label>

<div class="col-sm-9">
<input type="text" class="form-control"
id="firstname" name="firstname" required>
</div>
</div>
<div class="form-group">
<label for="lastname" class="col-sm-3
control-label">Lastname</label>

<div class="col-sm-9">
<input type="text" class="form-control"
id="lastname" name="lastname" required>
</div>
</div>
<div class="form-group">
<label for="position" class="col-sm-3 control-
label">Position</label>

<div class="col-sm-9">
<select class="form-control" id="position"
name="position" required>
<option value="" selected>- Select
-</option>
<?php
$sql = "SELECT * FROM positions";
$query = $conn->query($sql);
while($row = $query->fetch_assoc()){
echo "
<option value='".$row['id']."'>".
$row['description']."</option>
";
}
?>
</select>
</div>
</div>
<div class="form-group">
<label for="photo" class="col-sm-3 control-
label">Photo</label>

<div class="col-sm-9">
<input type="file" id="photo"
name="photo">
</div>
</div>
<div class="form-group">
<label for="platform" class="col-sm-3
control-label">Platform</label>

<div class="col-sm-9">
<textarea class="form-control"
id="platform" name="platform" rows="7"></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
<button type="submit" class="btn btn-primary
btn-flat" name="add"><i class="fa fa-save"></i>
Save</button>
</form>
</div>
</div>
</div>
</div>

<!-- Edit -->


<div class="modal fade" id="edit">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><b>Edit Voter</b></h4>
</div>
<div class="modal-body">
<form class="form-horizontal" method="POST"
action="candidates_edit.php">
<input type="hidden" class="id" name="id">
<div class="form-group">
<label for="edit_firstname" class="col-sm-3
control-label">Firstname</label>

<div class="col-sm-9">
<input type="text" class="form-control"
id="edit_firstname" name="firstname" required>
</div>
</div>
<div class="form-group">
<label for="edit_lastname" class="col-sm-3
control-label">Lastname</label>

<div class="col-sm-9">
<input type="text" class="form-control"
id="edit_lastname" name="lastname" required>
</div>
</div>
<div class="form-group">
<label for="edit_position" class="col-sm-3
control-label">Position</label>

<div class="col-sm-9">
<select class="form-control"
id="edit_position" name="position" required>
<option value="" selected
id="posselect"></option>
<?php
$sql = "SELECT * FROM positions";
$query = $conn->query($sql);
while($row = $query->fetch_assoc()){
echo "
<option value='".$row['id']."'>".
$row['description']."</option>
";
}
?>
</select>
</div>
</div>
<div class="form-group">
<label for="edit_platform" class="col-sm-3
control-label">Platform</label>

<div class="col-sm-9">
<textarea class="form-control"
id="edit_platform" name="platform"
rows="7"></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
<button type="submit" class="btn btn-success
btn-flat" name="edit"><i class="fa fa-check-square-
o"></i> Update</button>
</form>
</div>
</div>
</div>
</div>

<!-- Delete -->


<div class="modal fade" id="delete">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4
class="modal-title"><b>Deleting...</b></h4>
</div>
<div class="modal-body">
<form class="form-horizontal" method="POST"
action="candidates_delete.php">
<input type="hidden" class="id" name="id">
<div class="text-center">
<p>DELETE CANDIDATE</p>
<h2 class="bold fullname"></h2>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
<button type="submit" class="btn btn-danger
btn-flat" name="delete"><i class="fa fa-trash"></i>
Delete</button>
</form>
</div>
</div>
</div>
</div>

<!-- Update Photo -->


<div class="modal fade" id="edit_photo">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><b><span
class="fullname"></span></b></h4>
</div>
<div class="modal-body">
<form class="form-horizontal" method="POST"
action="candidates_photo.php"
enctype="multipart/form-data">
<input type="hidden" class="id" name="id">
<div class="form-group">
<label for="photo" class="col-sm-3 control-
label">Photo</label>

<div class="col-sm-9">
<input type="file" id="photo"
name="photo" required>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
<button type="submit" class="btn btn-success
btn-flat" name="upload"><i class="fa fa-check-square-
o"></i> Update</button>
</form>
</div>
</div>
</div>
</div>
 config_modal.php

<!-- Config -->


<div class="modal fade" id="config">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><b>Configure</b></h4>
</div>
<div class="modal-body">
<div class="text-center">
<?php
$parse = parse_ini_file('config.ini', FALSE,
INI_SCANNER_RAW);
$title = $parse['election_title'];
?>
<form class="form-horizontal" method="POST"
action="config_save.php?return=<?php echo
basename($_SERVER['PHP_SELF']); ?>">
<div class="form-group">
<label for="title" class="col-sm-3 control-
label">Title</label>

<div class="col-sm-9">
<input type="text" class="form-control"
id="title" name="title" value="<?php echo $title; ?>">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
<button type="submit" class="btn btn-success
btn-flat" name="save"><i class="fa fa-save"></i>
Save</button>
</form>
</div>
</div>
</div>
</div>

 conn.php

<?php
$conn = new mysqli('localhost', 'root', '',
'votesystem');

if ($conn->connect_error) {
die("Connection failed: " . $conn-
>connect_error);
}
?>

 footer.php

<footer class="main-footer">
<div class="pull-right hidden-xs">

</div>
<strong>ONLINE VOTING MANAGMENT SYSTEM</strong>
</footer>

 header.php

<!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.m
in.css">
<!-- iCheck for checkboxes and radio inputs -->
<link rel="stylesheet" href="../plugins/iCheck/all.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">
<!-- DataTables -->
<link rel="stylesheet"
href="../bower_components/datatables.net-bs/css/dataTabl
es.bootstrap.min.css">
<!-- daterange picker -->
<link rel="stylesheet"
href="../bower_components/bootstrap-daterangepicker/dat
erangepicker.css">
<!-- Bootstrap time Picker -->
<link rel="stylesheet"
href="../plugins/timepicker/bootstrap-timepicker.min.css">
<!-- bootstrap datepicker -->
<link rel="stylesheet"
href="../bower_components/bootstrap-datepicker/dist/css/b
ootstrap-datepicker.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:// -->
<!--[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]-->

<!-- Google Font -->


<link rel="stylesheet"
href="https://fonts.googleapis.com/css?
family=Source+Sans+Pro:300,400,600,700,300italic,400italic,
600italic">

<style type="text/css">
.bold{
font-weight:bold;
}

#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;
}
</style>
</head>

 menubar.php

<aside class="main-sidebar">
<!-- sidebar: style can be found in sidebar.less -->
<section class="sidebar">
<!-- Sidebar user panel -->
<div class="user-panel">
<div class="pull-left image">
<img src="<?php echo (!empty($user['photo'])) ?
'../images/'.$user['photo'] : '../images/profile.jpg'; ?>"
class="img-circle" alt="User Image">
</div>
<div class="pull-left info">
<p><?php echo $user['firstname'].' '.
$user['lastname']; ?></p>
<a><i class="fa fa-circle text-success"></i>
Online</a>
</div>
</div>
<!-- sidebar menu: : style can be found in sidebar.less
-->
<ul class="sidebar-menu" data-widget="tree">
<li class="header">REPORTS</li>
<li class=""><a href="home.php"><i class="fa fa-
dashboard"></i> <span>Dashboard</span></a></li>
<li class=""><a href="votes.php"><span
class="glyphicon glyphicon-lock"></span>
<span>Votes</span></a></li>
<li class="header">MANAGE</li>
<li class=""><a href="voters.php"><i class="fa fa-
users"></i> <span>Voters</span></a></li>
<li class=""><a href="positions.php"><i class="fa fa-
tasks"></i> <span>Positions</span></a></li>
<li class=""><a href="candidates.php"><i class="fa fa-
black-tie"></i> <span>Candidates</span></a></li>
<li class="header">SETTINGS</li>
<li class=""><a href="ballot.php"><i class="fa fa-file-
text"></i> <span>Ballot Position</span></a></li>
<li class=""><a href="#config" data-
toggle="modal"><i class="fa fa-cog"></i>
<span>Election Title</span></a></li>
</ul>
</section>
<!-- /.sidebar -->
</aside>
<?php include 'config_modal.php'; ?>

 navbar.php
<header class="main-header">
<!-- Logo -->
<a href="#" class="logo">
<!-- mini logo for sidebar mini 50x50 pixels -->
<span class="logo-mini"><b>V</b>TS</span>
<!-- logo for regular state and mobile devices -->
<span class="logo-lg"><b>Voting</b>System</span>
</a>
<!-- Header Navbar: style can be found in header.less --
>
<nav class="navbar navbar-static-top">
<!-- Sidebar toggle button-->
<a href="#" class="sidebar-toggle" data-toggle="push-
menu" role="button">
<span class="sr-only">Toggle navigation</span>
</a>

<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<!-- User Account: style can be found in
dropdown.less -->
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-
toggle="dropdown">
<img src="<?php echo (!empty($user['photo'])) ?
'../images/'.$user['photo'] : '../images/profile.jpg'; ?>"
class="user-image" alt="User Image">
<span class="hidden-xs"><?php echo
$user['firstname'].' '.$user['lastname']; ?></span>
</a>
<ul class="dropdown-menu">
<!-- User image -->
<li class="user-header">
<img src="<?php echo (!empty($user['photo'])) ?
'../images/'.$user['photo'] : '../images/profile.jpg'; ?>"
class="img-circle" alt="User Image">

<p>
<?php echo $user['firstname'].' '.
$user['lastname']; ?></br>
<small>ADMIN</small>
</p>
</li>
<li class="user-footer">
<div class="pull-left">
<a href="#profile" data-toggle="modal"
class="btn btn-default btn-flat"
id="admin_profile">Update</a>
</div>
<div class="pull-right">
<a href="logout.php" class="btn btn-default
btn-flat">Sign out</a>
</div>
</li>
</ul>
</li>
</ul>
</div>
</nav>
</header>
<?php include 'includes/profile_modal.php'; ?>

 positions_modal.php

<!-- Add -->


<div class="modal fade" id="addnew">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><b>Add New
Position</b></h4>
</div>
<div class="modal-body">
<form class="form-horizontal" method="POST"
action="positions_add.php">
<div class="form-group">
<label for="description" class="col-sm-3
control-label">Description</label>

<div class="col-sm-9">
<input type="text" class="form-control"
id="description" name="description" required>
</div>
</div>
<div class="form-group">
<label for="max_vote" class="col-sm-3
control-label">Maximum Vote</label>

<div class="col-sm-9">
<input type="number" class="form-control"
id="max_vote" name="max_vote" required>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
<button type="submit" class="btn btn-primary
btn-flat" name="add"><i class="fa fa-save"></i>
Save</button>
</form>
</div>
</div>
</div>
</div>

<!-- Edit -->


<div class="modal fade" id="edit">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><b>Edit
Position</b></h4>
</div>
<div class="modal-body">
<form class="form-horizontal" method="POST"
action="positions_edit.php">
<input type="hidden" class="id" name="id">
<div class="form-group">
<label for="edit_description" class="col-sm-3
control-label">Description</label>

<div class="col-sm-9">
<input type="text" class="form-control"
id="edit_description" name="description">
</div>
</div>
<div class="form-group">
<label for="edit_max_vote" class="col-sm-3
control-label">Maximum Vote</label>

<div class="col-sm-9">
<input type="number" class="form-control"
id="edit_max_vote" name="max_vote">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
<button type="submit" class="btn btn-success
btn-flat" name="edit"><i class="fa fa-check-square-
o"></i> Update</button>
</form>
</div>
</div>
</div>
</div>

<!-- Delete -->


<div class="modal fade" id="delete">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4
class="modal-title"><b>Deleting...</b></h4>
</div>
<div class="modal-body">
<form class="form-horizontal" method="POST"
action="positions_delete.php">
<input type="hidden" class="id" name="id">
<div class="text-center">
<p>DELETE POSITION</p>
<h2 class="bold description"></h2>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
<button type="submit" class="btn btn-danger
btn-flat" name="delete"><i class="fa fa-trash"></i>
Delete</button>
</form>
</div>
</div>
</div>
</div>

 profile_modal.php

<!-- Add -->


<div class="modal fade" id="profile">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><b>Admin
Profile</b></h4>
</div>
<div class="modal-body">
<form class="form-horizontal"
method="POST" action="profile_update.php?return=<?
php echo basename($_SERVER['PHP_SELF']); ?>"
enctype="multipart/form-data">
<div class="form-group">
<label for="username" class="col-sm-3
control-label">Username</label>

<div class="col-sm-9">
<input type="text" class="form-control"
id="username" name="username" value="<?php echo
$user['username']; ?>">
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-3
control-label">Password</label>

<div class="col-sm-9">
<input type="password" class="form-
control" id="password" name="password" value="<?
php echo $user['password']; ?>">
</div>
</div>
<div class="form-group">
<label for="firstname" class="col-sm-3
control-label">Firstname</label>

<div class="col-sm-9">
<input type="text" class="form-control"
id="firstname" name="firstname" value="<?php echo
$user['firstname']; ?>">
</div>
</div>
<div class="form-group">
<label for="lastname" class="col-sm-3
control-label">Lastname</label>

<div class="col-sm-9">
<input type="text" class="form-control"
id="lastname" name="lastname" value="<?php echo
$user['lastname']; ?>">
</div>
</div>
<div class="form-group">
<label for="photo" class="col-sm-3 control-
label">Photo:</label>

<div class="col-sm-9">
<input type="file" id="photo"
name="photo">
</div>
</div>
<hr>
<div class="form-group">
<label for="curr_password" class="col-sm-3
control-label">Current Password:</label>

<div class="col-sm-9">
<input type="password" class="form-
control" id="curr_password" name="curr_password"
placeholder="input current password to save changes"
required>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
<button type="submit" class="btn btn-success
btn-flat" name="save"><i class="fa fa-check-square-
o"></i> Save</button>
</form>
</div>
</div>
</div>
</div>

 scripts.php

<!-- jQuery 3 -->


<script
src="../bower_components/jquery/dist/jquery.min.js"><
/script>
<!-- jQuery UI 1.11.4 -->
<script src="../bower_components/jquery-ui/jquery-
ui.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script
src="../bower_components/bootstrap/dist/js/bootstrap.
min.js"></script>
<!-- iCheck 1.0.1 -->
<script src="../plugins/iCheck/icheck.min.js"></script>
<!-- Moment JS -->
<script
src="../bower_components/moment/moment.js"></scri
pt>
<!-- DataTables -->
<script
src="../bower_components/datatables.net/js/jquery.dat
aTables.min.js"></script>
<script
src="../bower_components/datatables.net-bs/js/dataTa
bles.bootstrap.min.js"></script>
<!-- ChartJS -->
<script
src="../bower_components/chart.js/Chart.js"></script>
<!-- ChartJS Horizontal Bar -->
<script
src="../bower_components/chart.js/Chart.HorizontalBar
.js"></script>
<!-- daterangepicker -->
<script
src="../bower_components/moment/min/moment.min.
js"></script>
<script src="../bower_components/bootstrap-
daterangepicker/daterangepicker.js"></script>
<!-- datepicker -->
<script src="../bower_components/bootstrap-
datepicker/dist/js/bootstrap-datepicker.min.js"></
script>
<!-- bootstrap time picker -->
<script src="../plugins/timepicker/bootstrap-
timepicker.min.js"></script>
<!-- Slimscroll -->
<script
src="../bower_components/jquery-slimscroll/jquery.sli
mscroll.min.js"></script>
<!-- FastClick -->
<script
src="../bower_components/fastclick/lib/fastclick.js"></s
cript>
<!-- AdminLTE App -->
<script src="../dist/js/adminlte.min.js"></script>
<!-- Active Script -->
<script>
$(function(){
/** add active class and stay opened when selected
*/
var url = window.location;

// for sidebar menu entirely but not cover treeview


$('ul.sidebar-menu a').filter(function() {
return this.href == url;
}).parent().addClass('active');

// for treeview
$('ul.treeview-menu a').filter(function() {
return this.href == url;
}).parentsUntil(".sidebar-menu > .treeview-
menu").addClass('active');

});
</script>
<!-- Data Table Initialize -->
<script>
$(function () {
$('#example1').DataTable()
$('#example2').DataTable({
'paging' : true,
'lengthChange': false,
'searching' : false,
'ordering' : true,
'info' : true,
'autoWidth' : false
})
})
</script>
<!-- Date and Timepicker -->
<script>
$(function(){
//Date picker
$('#datepicker_add').datepicker({
autoclose: true,
format: 'yyyy-mm-dd'
})
$('#datepicker_edit').datepicker({
autoclose: true,
format: 'yyyy-mm-dd'
})
});
</script>

 session.php

<?php
session_start();
include 'includes/conn.php';

if(!isset($_SESSION['admin']) ||
trim($_SESSION['admin']) == ''){
header('location: index.php');
}

$sql = "SELECT * FROM admin WHERE id = '".


$_SESSION['admin']."'";
$query = $conn->query($sql);
$user = $query->fetch_assoc();

?>

 slugify.php
<?php

function slugify($string){
$preps = array('in', 'at', 'on', 'by', 'into', 'off', 'onto',
'from', 'to', 'with', 'a', 'an', 'the', 'using', 'for');
$pattern = '/\b(?:' . join('|', $preps) . ')\b/i';
$string = preg_replace($pattern, '', $string);
$string = preg_replace('~[^\\pL\d]+~u', '-', $string);
$string = trim($string, '-');
$string = iconv('utf-8', 'us-ascii//TRANSLIT', $string);
$string = strtolower($string);
$string = preg_replace('~[^-\w]+~', '', $string);

return $string;

?>

 voters_modal.php

<!-- Add -->


<div class="modal fade" id="addnew">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><b>Add New
Voter</b></h4>
</div>
<div class="modal-body">
<form class="form-horizontal" method="POST"
action="voters_add.php" enctype="multipart/form-
data">
<div class="form-group">
<label for="firstname" class="col-sm-3
control-label">Firstname</label>

<div class="col-sm-9">
<input type="text" class="form-control"
id="firstname" name="firstname" required>
</div>
</div>
<div class="form-group">
<label for="lastname" class="col-sm-3
control-label">Lastname</label>

<div class="col-sm-9">
<input type="text" class="form-control"
id="lastname" name="lastname" required>
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-3
control-label">Password</label>
<div class="col-sm-9">
<input type="password" class="form-
control" id="password" name="password" required>
</div>
</div>
<div class="form-group">
<label for="photo" class="col-sm-3 control-
label">Photo</label>

<div class="col-sm-9">
<input type="file" id="photo"
name="photo">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
<button type="submit" class="btn btn-primary
btn-flat" name="add"><i class="fa fa-save"></i>
Save</button>
</form>
</div>
</div>
</div>
</div>

<!-- Edit -->


<div class="modal fade" id="edit">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><b>Edit Voter</b></h4>
</div>
<div class="modal-body">
<form class="form-horizontal" method="POST"
action="voters_edit.php">
<input type="hidden" class="id" name="id">
<div class="form-group">
<label for="edit_firstname" class="col-sm-3
control-label">Firstname</label>

<div class="col-sm-9">
<input type="text" class="form-control"
id="edit_firstname" name="firstname">
</div>
</div>
<div class="form-group">
<label for="edit_lastname" class="col-sm-3
control-label">Lastname</label>

<div class="col-sm-9">
<input type="text" class="form-control"
id="edit_lastname" name="lastname">
</div>
</div>
<div class="form-group">
<label for="edit_password" class="col-sm-3
control-label">Password</label>

<div class="col-sm-9">
<input type="password" class="form-
control" id="edit_password" name="password">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
<button type="submit" class="btn btn-success
btn-flat" name="edit"><i class="fa fa-check-square-
o"></i> Update</button>
</form>
</div>
</div>
</div>
</div>

<!-- Delete -->


<div class="modal fade" id="delete">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4
class="modal-title"><b>Deleting...</b></h4>
</div>
<div class="modal-body">
<form class="form-horizontal" method="POST"
action="voters_delete.php">
<input type="hidden" class="id" name="id">
<div class="text-center">
<p>DELETE VOTER</p>
<h2 class="bold fullname"></h2>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
<button type="submit" class="btn btn-danger
btn-flat" name="delete"><i class="fa fa-trash"></i>
Delete</button>
</form>
</div>
</div>
</div>
</div>

<!-- Update Photo -->


<div class="modal fade" id="edit_photo">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><b><span
class="fullname"></span></b></h4>
</div>
<div class="modal-body">
<form class="form-horizontal" method="POST"
action="voters_photo.php" enctype="multipart/form-
data">
<input type="hidden" class="id" name="id">
<div class="form-group">
<label for="photo" class="col-sm-3 control-
label">Photo</label>

<div class="col-sm-9">
<input type="file" id="photo"
name="photo" required>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
<button type="submit" class="btn btn-success
btn-flat" name="upload"><i class="fa fa-check-square-
o"></i> Update</button>
</form>
</div>
</div>
</div>
</div>

 votes_modal.php

<!-- Reset -->


<div class="modal fade" id="reset">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4
class="modal-title"><b>Reseting...</b></h4>
</div>
<div class="modal-body">
<div class="text-center">
<p>RESET VOTES</p>
<h4>This will delete all votes and counting
back to 0.</h4>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
<a href="votes_reset.php" class="btn btn-
danger btn-flat"><i class="fa fa-refresh"></i> Reset</a>
</div>
</div>
</div>
</div>

Outside the includes folder

 ballot.php

<?php include 'includes/session.php'; ?>


<?php include 'includes/header.php'; ?>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

<?php include 'includes/navbar.php'; ?>


<?php include 'includes/menubar.php'; ?>

<!-- Content Wrapper. Contains page content -->


<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Ballot Position
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i>
Home</a></li>
<li class="active">Ballot Preview</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'>&times;</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'>&times;</button>
<h4><i class='icon fa fa-check'></i>
Success!</h4>
".$_SESSION['success']."
</div>
";
unset($_SESSION['success']);
}
?>

<div class="row">
<div class="col-xs-10 col-xs-offset-1" id="content">
</div>
</div>

</section>

</div>

<?php include 'includes/footer.php'; ?>


</div>
<?php include 'includes/scripts.php'; ?>
<script>
$(function(){
fetch();

$(document).on('click', '.reset', function(e){


e.preventDefault();
var desc = $(this).data('desc');
$('.'+desc).iCheck('uncheck');
});

$(document).on('click', '.moveup', function(e){


e.preventDefault();
var id = $(this).data('id');
$('#'+id).animate({
'marginTop' : "-300px"
});
$.ajax({
type: 'POST',
url: 'ballot_up.php',
data:{id:id},
dataType: 'json',
success: function(response){
if(!response.error){
fetch();
}
}
});
});

$(document).on('click', '.movedown', function(e){


e.preventDefault();
var id = $(this).data('id');
$('#'+id).animate({
'marginTop' : "+300px"
});
$.ajax({
type: 'POST',
url: 'ballot_down.php',
data:{id:id},
dataType: 'json',
success: function(response){
if(!response.error){
fetch();
}
}
});
});

});

function fetch(){
$.ajax({
type: 'POST',
url: 'ballot_fetch.php',
dataType: 'json',
success: function(response){
$('#content').html(response).iCheck({checkboxClass:
'icheckbox_flat-green',radioClass: 'iradio_flat-green'});
}
});
}
</script>
</body>
</html>

 ballot_down.php

<?php
include 'includes/session.php';

if(isset($_POST['id'])){
$id = $_POST['id'];
$sql = "SELECT * FROM positions";
$pquery = $conn->query($sql);

$output = array('error'=>false);

$sql = "SELECT * FROM positions WHERE


id='$id'";
$query = $conn->query($sql);
$row = $query->fetch_assoc();

$priority = $row['priority'] + 1;

if($priority > $pquery->num_rows){


$output['error'] = true;
$output['message'] = 'This position is
already at the bottom';
}
else{
$sql = "UPDATE positions SET priority =
priority - 1 WHERE priority = '$priority'";
$conn->query($sql);

$sql = "UPDATE positions SET priority =


'$priority' WHERE id = '$id'";
$conn->query($sql);
}

echo json_encode($output);
}

?>

 ballot_fetch.php

<?php
include 'includes/session.php';
include 'includes/slugify.php';

$sql = "SELECT * FROM positions";


$pquery = $conn->query($sql);

$output = '';
$candidate = '';

$sql = "SELECT * FROM positions ORDER BY priority


ASC";
$query = $conn->query($sql);
$num = 1;
while($row = $query->fetch_assoc()){
$input = ($row['max_vote'] > 1) ? '<input
type="checkbox" class="flat-red
'.slugify($row['description']).'"
name="'.slugify($row['description'])."[]".'">' : '<input
type="radio" class="flat-red
'.slugify($row['description']).'"
name="'.slugify($row['description']).'">';
$sql = "SELECT * FROM candidates WHERE
position_id='".$row['id']."'";
$cquery = $conn->query($sql);
while($crow = $cquery->fetch_assoc()){
$image = (!empty($crow['photo'])) ?
'../images/'.$crow['photo'] : '../images/profile.jpg';
$candidate .= '
<li>
'.$input.'<button class="btn
btn-primary btn-sm btn-flat clist"><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>
';
}

$instruct = ($row['max_vote'] > 1) ? 'You may


select up to '.$row['max_vote'].' candidates' : 'Select
only one candidate';

$updisable = ($row['priority'] == 1) ? 'disabled'


: '';
$downdisable = ($row['priority'] == $pquery-
>num_rows) ? 'disabled' : '';

$output .= '
<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 class="pull-right
box-tools">
<button type="button"
class="btn btn-default btn-sm moveup" data-id="'.
$row['id'].'" '.$updisable.'><i class="fa fa-arrow-up"></i>
</button>
<button type="button"
class="btn btn-default btn-sm movedown" data-id="'.
$row['id'].'" '.$downdisable.'><i class="fa fa-arrow-
down"></i></button>
</div>
</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>
';

$sql = "UPDATE positions SET priority = '$num'


WHERE id = '".$row['id']."'";
$conn->query($sql);

$num++;
$candidate = '';
}

echo json_encode($output);

?>

 ballot_up.php

<?php
include 'includes/session.php';

if(isset($_POST['id'])){
$id = $_POST['id'];
$output = array('error'=>false);

$sql = "SELECT * FROM positions WHERE


id='$id'";
$query = $conn->query($sql);
$row = $query->fetch_assoc();

$priority = $row['priority'] - 1;

if($priority == 0){
$output['error'] = true;
$output['message'] = 'This position is
already at the top';
}
else{
$sql = "UPDATE positions SET priority =
priority + 1 WHERE priority = '$priority'";
$conn->query($sql);

$sql = "UPDATE positions SET priority =


'$priority' WHERE id = '$id'";
$conn->query($sql);
}

echo json_encode($output);

?>
 candidates.php

<?php include 'includes/session.php'; ?>


<?php include 'includes/header.php'; ?>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

<?php include 'includes/navbar.php'; ?>


<?php include 'includes/menubar.php'; ?>

<!-- Content Wrapper. Contains page content -->


<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Candidates List
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i>
Home</a></li>
<li class="active">Candidates</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'>&times;</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'>&times;</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>
<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>
<?php include 'includes/footer.php'; ?>
<?php include 'includes/candidates_modal.php'; ?>
</div>
<?php include 'includes/scripts.php'; ?>
<script>
$(function(){
$(document).on('click', '.edit', function(e){
e.preventDefault();
$('#edit').modal('show');
var id = $(this).data('id');
getRow(id);
});

$(document).on('click', '.delete', function(e){


e.preventDefault();
$('#delete').modal('show');
var id = $(this).data('id');
getRow(id);
});

$(document).on('click', '.photo', function(e){


e.preventDefault();
var id = $(this).data('id');
getRow(id);
});

$(document).on('click', '.platform', function(e){


e.preventDefault();
var id = $(this).data('id');
getRow(id);
});

});

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.d
escription);
$('#edit_platform').val(response.platform);
$('.fullname').html(response.firstname+'
'+response.lastname);
$('#desc').html(response.platform);
}
});
}
</script>
</body>
</html>

 candidates_add.php
<?php
include 'includes/session.php';

if(isset($_POST['add'])){
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$position = $_POST['position'];
$platform = $_POST['platform'];
$filename = $_FILES['photo']['name'];
if(!empty($filename)){
move_uploaded_file($_FILES['photo']
['tmp_name'], '../images/'.$filename);
}

$sql = "INSERT INTO candidates (position_id,


firstname, lastname, photo, platform) VALUES
('$position', '$firstname', '$lastname', '$filename',
'$platform')";
if($conn->query($sql)){
$_SESSION['success'] = 'Candidate added
successfully';
}
else{
$_SESSION['error'] = $conn->error;
}

}
else{
$_SESSION['error'] = 'Fill up add form first';
}

header('location: candidates.php');
?>

 candidates_delete.php

<?php
include 'includes/session.php';

if(isset($_POST['delete'])){
$id = $_POST['id'];
$sql = "DELETE FROM candidates WHERE id =
'$id'";
if($conn->query($sql)){
$_SESSION['success'] = 'Candidate
deleted successfully';
}
else{
$_SESSION['error'] = $conn->error;
}
}
else{
$_SESSION['error'] = 'Select item to delete
first';
}

header('location: candidates.php');
?>

 candidates_edit.php

<?php
include 'includes/session.php';

if(isset($_POST['edit'])){
$id = $_POST['id'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$position = $_POST['position'];
$platform = $_POST['platform'];

$sql = "UPDATE candidates SET firstname =


'$firstname', lastname = '$lastname', position_id =
'$position', platform = '$platform' WHERE id = '$id'";
if($conn->query($sql)){
$_SESSION['success'] = 'Candidate
updated successfully';
}
else{
$_SESSION['error'] = $conn->error;
}
}
else{
$_SESSION['error'] = 'Fill up edit form first';
}

header('location: candidates.php');

?>

 candidates_photo.php

<?php
include 'includes/session.php';

if(isset($_POST['upload'])){
$id = $_POST['id'];
$filename = $_FILES['photo']['name'];
if(!empty($filename)){
move_uploaded_file($_FILES['photo']
['tmp_name'], '../images/'.$filename);
}

$sql = "UPDATE candidates SET photo =


'$filename' WHERE id = '$id'";
if($conn->query($sql)){
$_SESSION['success'] = 'Photo updated
successfully';
}
else{
$_SESSION['error'] = $conn->error;
}

}
else{
$_SESSION['error'] = 'Select candidate to
update photo first';
}

header('location: candidates.php');
?>

 candidates_row.php

<?php
include 'includes/session.php';

if(isset($_POST['id'])){
$id = $_POST['id'];
$sql = "SELECT *, candidates.id AS canid FROM
candidates LEFT JOIN positions ON
positions.id=candidates.position_id WHERE
candidates.id = '$id'";
$query = $conn->query($sql);
$row = $query->fetch_assoc();

echo json_encode($row);
}
?>

 config_save.php

<?php
include 'includes/session.php';
$return = 'home.php';
if(isset($_GET['return'])){
$return = $_GET['return'];
}

if(isset($_POST['save'])){
$title = $_POST['title'];

$file = 'config.ini';
$content = 'election_title = '.$title;

file_put_contents($file, $content);

$_SESSION['success'] = 'Election title updated


successfully';

}
else{
$_SESSION['error'] = "Fill up config form first";
}

header('location: '.$return);

?>

 home.php
<?php include 'includes/session.php'; ?>
<?php include 'includes/slugify.php'; ?>
<?php include 'includes/header.php'; ?>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

<?php include 'includes/navbar.php'; ?>


<?php include 'includes/menubar.php'; ?>

<!-- Content Wrapper. Contains page content -->


<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Dashboard
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i>
Home</a></li>
<li class="active">Dashboard</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'>&times;</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'>&times;</button>
<h4><i class='icon fa fa-check'></i>
Success!</h4>
".$_SESSION['success']."
</div>
";
unset($_SESSION['success']);
}
?>
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-aqua">
<div class="inner">
<?php
$sql = "SELECT * FROM positions";
$query = $conn->query($sql);

echo "<h3>".$query->num_rows."</h3>";
?>

<p>No. of Positions</p>
</div>
<div class="icon">
<i class="fa fa-tasks"></i>
</div>
<a href="positions.php" class="small-box-
footer">More info <i class="fa
fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-green">
<div class="inner">
<?php
$sql = "SELECT * FROM candidates";
$query = $conn->query($sql);

echo "<h3>".$query->num_rows."</h3>";
?>

<p>No. of Candidates</p>
</div>
<div class="icon">
<i class="fa fa-black-tie"></i>
</div>
<a href="candidates.php" class="small-box-
footer">More info <i class="fa
fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-yellow">
<div class="inner">
<?php
$sql = "SELECT * FROM voters";
$query = $conn->query($sql);

echo "<h3>".$query->num_rows."</h3>";
?>

<p>Total Voters</p>
</div>
<div class="icon">
<i class="fa fa-users"></i>
</div>
<a href="voters.php" class="small-box-
footer">More info <i class="fa
fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-red">
<div class="inner">
<?php
$sql = "SELECT * FROM votes GROUP BY
voters_id";
$query = $conn->query($sql);

echo "<h3>".$query->num_rows."</h3>";
?>

<p>Voters Voted</p>
</div>
<div class="icon">
<i class="fa fa-edit"></i>
</div>
<a href="votes.php" class="small-box-
footer">More info <i class="fa
fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
</div>

<div class="row">
<div class="col-xs-12">
<h3>Votes Tally

</h3>
</div>
</div>

<?php
$sql = "SELECT * FROM positions ORDER BY priority
ASC";
$query = $conn->query($sql);
$inc = 2;
while($row = $query->fetch_assoc()){
$inc = ($inc == 2) ? 1 : $inc+1;
if($inc == 1) echo "<div class='row'>";
echo "
<div class='col-sm-6'>
<div class='box box-solid'>
<div class='box-header with-border'>
<h4 class='box-title'><b>".
$row['description']."</b></h4>
</div>
<div class='box-body'>
<div class='chart'>
<canvas id='".slugify($row['description'])."'
style='height:200px'></canvas>
</div>
</div>
</div>
</div>
";
if($inc == 2) echo "</div>";
}
if($inc == 1) echo "<div
class='col-sm-6'></div></div>";
?>

</section>
<!-- right col -->
</div>
<?php include 'includes/footer.php'; ?>

</div>
<!-- ./wrapper -->

<?php include 'includes/scripts.php'; ?>


<?php
$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);
$carray = array();
$varray = array();
while($crow = $cquery->fetch_assoc()){
array_push($carray, $crow['lastname']);
$sql = "SELECT * FROM votes WHERE candidate_id =
'".$crow['id']."'";
$vquery = $conn->query($sql);
array_push($varray, $vquery->num_rows);
}
$carray = json_encode($carray);
$varray = json_encode($varray);
?>
<script>
$(function(){
var rowid = '<?php echo $row['id']; ?>';
var description = '<?php echo
slugify($row['description']); ?>';
var barChartCanvas = $
('#'+description).get(0).getContext('2d')
var barChart = new Chart(barChartCanvas)
var barChartData = {
labels : <?php echo $carray; ?>,
datasets: [
{
label : 'Votes',
fillColor : 'rgba(60,141,188,0.9)',
strokeColor : 'rgba(60,141,188,0.8)',
pointColor : '#3b8bba',
pointStrokeColor : 'rgba(60,141,188,1)',
pointHighlightFill : '#fff',
pointHighlightStroke: 'rgba(60,141,188,1)',
data : <?php echo $varray; ?>
}
]
}
var barChartOptions ={
//Boolean - Whether the scale should start at zero,
or an order of magnitude down from the lowest value
scaleBeginAtZero : true,
//Boolean - Whether grid lines are shown across the
chart
scaleShowGridLines : true,
//String - Colour of the grid lines
scaleGridLineColor : 'rgba(0,0,0,.05)',
//Number - Width of the grid lines
scaleGridLineWidth : 1,
//Boolean - Whether to show horizontal lines
(except X axis)
scaleShowHorizontalLines: true,
//Boolean - Whether to show vertical lines (except Y
axis)
scaleShowVerticalLines : true,
//Boolean - If there is a stroke on each bar
barShowStroke : true,
//Number - Pixel width of the bar stroke
barStrokeWidth : 2,
//Number - Spacing between each of the X value
sets
barValueSpacing : 5,
//Number - Spacing between data sets within X
values
barDatasetSpacing : 1,
//String - A legend template
legendTemplate : '<ul class="<
%=name.toLowerCase()%>-legend"><% for (var i=0;
i<datasets.length; i++){%><li><span style="background-
color:<%=datasets[i].fillColor%>"></span><
%if(datasets[i].label){%><%=datasets[i].label%><%}
%></li><%}%></ul>',
//Boolean - whether to make the chart responsive
responsive : true,
maintainAspectRatio : true
}

barChartOptions.datasetFill = false
var myChart = barChart.HorizontalBar(barChartData,
barChartOptions)

//document.getElementById('legend_'+rowid).innerHT
ML = myChart.generateLegend();
});
</script>
<?php
}
?>
</body>
</html>
 index.php

<?php
session_start();
if(isset($_SESSION['admin'])){
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>

<form action="login.php" method="POST">


<div class="form-group has-feedback">
<input type="text" class="form-control"
name="username" placeholder="Username" required>
<span class="glyphicon glyphicon-user form-
control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" class="form-control"
name="password" placeholder="Password" required>
<span class="glyphicon glyphicon-lock form-
control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-4">
<button type="submit" class="btn
btn-primary btn-block btn-flat" name="login"><i
class="fa fa-sign-in"></i> Sign In</button>
</div>
</div>
</form>
</div>
<?php
if(isset($_SESSION['error'])){
echo "
<div class='callout callout-danger
text-center mt20'>
<p>".$_SESSION['error']."</p>
</div>
";
unset($_SESSION['error']);
}
?>
</div>

<?php include 'includes/scripts.php' ?>


</body>
</html>

 login.php

<?php
session_start();
include 'includes/conn.php';

if(isset($_POST['login'])){
$username = $_POST['username'];
$password = $_POST['password'];

$sql = "SELECT * FROM admin WHERE


username = '$username'";
$query = $conn->query($sql);
if($query->num_rows < 1){
$_SESSION['error'] = 'Cannot find account
with the username';
}
else{
$row = $query->fetch_assoc();
if(password_verify($password,
$row['password'])){
$_SESSION['admin'] = $row['id'];
}
else{
$_SESSION['error'] = 'Incorrect
password';
}
}

}
else{
$_SESSION['error'] = 'Input admin credentials
first';
}

header('location: index.php');

?>

 logout.php

<?php
session_start();
session_destroy();

header('location: /votesystem/index.php');
?>

 positions.php

<?php include 'includes/session.php'; ?>


<?php include 'includes/header.php'; ?>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

<?php include 'includes/navbar.php'; ?>


<?php include 'includes/menubar.php'; ?>

<!-- Content Wrapper. Contains page content -->


<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Positions
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i>
Home</a></li>
<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'>&times;</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'>&times;</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 "
<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>

<?php include 'includes/footer.php'; ?>


<?php include 'includes/positions_modal.php'; ?>
</div>
<?php include 'includes/scripts.php'; ?>
<script>
$(function(){
$(document).on('click', '.edit', function(e){
e.preventDefault();
$('#edit').modal('show');
var id = $(this).data('id');
getRow(id);
});
$(document).on('click', '.delete', function(e){
e.preventDefault();
$('#delete').modal('show');
var id = $(this).data('id');
getRow(id);
});

});

function getRow(id){
$.ajax({
type: 'POST',
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>

 positions_add.php

<?php
include 'includes/session.php';

if(isset($_POST['add'])){
$description = $_POST['description'];
$max_vote = $_POST['max_vote'];

$sql = "SELECT * FROM positions ORDER BY


priority DESC LIMIT 1";
$query = $conn->query($sql);
$row = $query->fetch_assoc();

$priority = $row['priority'] + 1;

$sql = "INSERT INTO positions (description,


max_vote, priority) VALUES ('$description', '$max_vote',
'$priority')";
if($conn->query($sql)){
$_SESSION['success'] = 'Position added
successfully';
}
else{
$_SESSION['error'] = $conn->error;
}

}
else{
$_SESSION['error'] = 'Fill up add form first';
}

header('location: positions.php');
?>

 position_delete.php

<?php
include 'includes/session.php';

if(isset($_POST['delete'])){
$id = $_POST['id'];
$sql = "DELETE FROM positions WHERE id =
'$id'";
if($conn->query($sql)){
$_SESSION['success'] = 'Position deleted
successfully';
}
else{
$_SESSION['error'] = $conn->error;
}
}
else{
$_SESSION['error'] = 'Select item to delete
first';
}

header('location: positions.php');

?>

 position_edit.php
<?php
include 'includes/session.php';

if(isset($_POST['edit'])){
$id = $_POST['id'];
$description = $_POST['description'];
$max_vote = $_POST['max_vote'];

$sql = "UPDATE positions SET description =


'$description', max_vote = '$max_vote' WHERE id =
'$id'";
if($conn->query($sql)){
$_SESSION['success'] = 'Position updated
successfully';
}
else{
$_SESSION['error'] = $conn->error;
}
}
else{
$_SESSION['error'] = 'Fill up edit form first';
}

header('location: positions.php');

?>

 position_row.php

<?php
include 'includes/session.php';

if(isset($_POST['id'])){
$id = $_POST['id'];
$sql = "SELECT * FROM positions WHERE id =
'$id'";
$query = $conn->query($sql);
$row = $query->fetch_assoc();

echo json_encode($row);
}
?>

 profile_update.php

<?php
include 'includes/session.php';

if(isset($_GET['return'])){
$return = $_GET['return'];

}
else{
$return = 'home.php';
}

if(isset($_POST['save'])){
$curr_password = $_POST['curr_password'];
$username = $_POST['username'];
$password = $_POST['password'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$photo = $_FILES['photo']['name'];
if(password_verify($curr_password,
$user['password'])){
if(!empty($photo)){

move_uploaded_file($_FILES['photo']['tmp_name'],
'../images/'.$photo);
$filename = $photo;
}
else{
$filename = $user['photo'];
}

if($password == $user['password']){
$password = $user['password'];
}
else{
$password =
password_hash($password, PASSWORD_DEFAULT);
}

$sql = "UPDATE admin SET username =


'$username', password = '$password', firstname =
'$firstname', lastname = '$lastname', photo = '$filename'
WHERE id = '".$user['id']."'";
if($conn->query($sql)){
$_SESSION['success'] = 'Admin
profile updated successfully';
}
else{
$_SESSION['error'] = $conn->error;
}

}
else{
$_SESSION['error'] = 'Incorrect password';
}
}
else{
$_SESSION['error'] = 'Fill up required details
first';
}

header('location:'.$return);

?>

 voters.php

<?php include 'includes/session.php'; ?>


<?php include 'includes/header.php'; ?>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

<?php include 'includes/navbar.php'; ?>


<?php include 'includes/menubar.php'; ?>

<!-- Content Wrapper. Contains page content -->


<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Voters List
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i>
Home</a></li>
<li class="active">Voters</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'>&times;</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'>&times;</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>
<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>

<?php include 'includes/footer.php'; ?>


<?php include 'includes/voters_modal.php'; ?>
</div>
<?php include 'includes/scripts.php'; ?>
<script>
$(function(){
$(document).on('click', '.edit', function(e){
e.preventDefault();
$('#edit').modal('show');
var id = $(this).data('id');
getRow(id);
});

$(document).on('click', '.delete', function(e){


e.preventDefault();
$('#delete').modal('show');
var id = $(this).data('id');
getRow(id);
});

$(document).on('click', '.photo', function(e){


e.preventDefault();
var id = $(this).data('id');
getRow(id);
});

});

function getRow(id){
$.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>

 voters_add.php
<?php
include 'includes/session.php';

if(isset($_POST['add'])){
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$password =
password_hash($_POST['password'],
PASSWORD_DEFAULT);
$filename = $_FILES['photo']['name'];
if(!empty($filename)){
move_uploaded_file($_FILES['photo']
['tmp_name'], '../images/'.$filename);
}
//generate voters id
$set =
'123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKL
MNOPQRSTUVWXYZ';
$voter = substr(str_shuffle($set), 0, 15);

$sql = "INSERT INTO voters (voters_id,


password, firstname, lastname, photo) VALUES ('$voter',
'$password', '$firstname', '$lastname', '$filename')";
if($conn->query($sql)){
$_SESSION['success'] = 'Voter added
successfully';
}
else{
$_SESSION['error'] = $conn->error;
}
}
else{
$_SESSION['error'] = 'Fill up add form first';
}

header('location: voters.php');
?>

 voters_delete.php

<?php
include 'includes/session.php';

if(isset($_POST['delete'])){
$id = $_POST['id'];
$sql = "DELETE FROM voters WHERE id =
'$id'";
if($conn->query($sql)){
$_SESSION['success'] = 'Voter deleted
successfully';
}
else{
$_SESSION['error'] = $conn->error;
}
}
else{
$_SESSION['error'] = 'Select item to delete
first';
}
header('location: voters.php');

?>

 voters_edit.php

<?php
include 'includes/session.php';

if(isset($_POST['edit'])){
$id = $_POST['id'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$password = $_POST['password'];

$sql = "SELECT * FROM voters WHERE id =


$id";
$query = $conn->query($sql);
$row = $query->fetch_assoc();

if($password == $row['password']){
$password = $row['password'];
}
else{
$password = password_hash($password,
PASSWORD_DEFAULT);
}
$sql = "UPDATE voters SET firstname =
'$firstname', lastname = '$lastname', password =
'$password' WHERE id = '$id'";
if($conn->query($sql)){
$_SESSION['success'] = 'Voter updated
successfully';
}
else{
$_SESSION['error'] = $conn->error;
}
}
else{
$_SESSION['error'] = 'Fill up edit form first';
}

header('location: voters.php');

?>

 voters_photo.php

<?php
include 'includes/session.php';

if(isset($_POST['upload'])){
$id = $_POST['id'];
$filename = $_FILES['photo']['name'];
if(!empty($filename)){
move_uploaded_file($_FILES['photo']
['tmp_name'], '../images/'.$filename);
}

$sql = "UPDATE voters SET photo = '$filename'


WHERE id = '$id'";
if($conn->query($sql)){
$_SESSION['success'] = 'Photo updated
successfully';
}
else{
$_SESSION['error'] = $conn->error;
}

}
else{
$_SESSION['error'] = 'Select voter to update
photo first';
}

header('location: voters.php');
?>

 voters_row.php

<?php
include 'includes/session.php';

if(isset($_POST['id'])){
$id = $_POST['id'];
$sql = "SELECT * FROM voters WHERE id
= '$id'";
$query = $conn->query($sql);
$row = $query->fetch_assoc();

echo json_encode($row);
}
?>

 votes.php

<?php include 'includes/session.php'; ?>


<?php include 'includes/header.php'; ?>
<body class="hold-transition skin-blue sidebar-
mini">
<div class="wrapper">

<?php include 'includes/navbar.php'; ?>


<?php include 'includes/menubar.php'; ?>

<!-- Content Wrapper. Contains page content -->


<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Votes
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa
fa-dashboard"></i> Home</a></li>
<li class="active">Votes</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'>&times;</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'>&times;</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="#reset" data-toggle="modal"
class="btn btn-danger btn-sm btn-flat"><i class="fa
fa-refresh"></i> Reset</a>
</div>
<div class="box-body">
<table id="example1" class="table table-
bordered">
<thead>
<th class="hidden"></th>
<th>Position</th>
<th>Candidate</th>
<th>Voter</th>
</thead>
<tbody>
<?php
$sql = "SELECT *, candidates.firstname
AS canfirst, candidates.lastname AS canlast,
voters.firstname AS votfirst, voters.lastname AS
votlast FROM votes LEFT JOIN positions ON
positions.id=votes.position_id LEFT JOIN candidates
ON candidates.id=votes.candidate_id LEFT JOIN
voters ON voters.id=votes.voters_id ORDER BY
positions.priority ASC";
$query = $conn->query($sql);
while($row = $query->fetch_assoc()){
echo "
<tr>
<td class='hidden'></td>
<td>".$row['description']."</td>
<td>".$row['canfirst'].' '.
$row['canlast']."</td>
<td>".$row['votfirst'].' '.
$row['votlast']."</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
</div>

<?php include 'includes/footer.php'; ?>


<?php include 'includes/votes_modal.php'; ?>
</div>
<?php include 'includes/scripts.php'; ?>
</body>
</html>
 votes_reset.php

<?php
include 'includes/session.php';

$sql = "DELETE FROM votes";


if($conn->query($sql)){
$_SESSION['success'] = "Votes reset
successfully";
}
else{
$_SESSION['error'] = "Something went
wrong in reseting";
}

header('location: votes.php');

?>

 votesystem.sql

-- phpMyAdmin SQL Dump


-- version 4.7.9
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: May 18, 2018 at 07:34 AM
-- Server version: 10.1.31-MariaDB
-- PHP Version: 7.1.15
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";

/*!40101 SET
@OLD_CHARACTER_SET_CLIENT=@@CHARACTER_
SET_CLIENT */;
/*!40101 SET
@OLD_CHARACTER_SET_RESULTS=@@CHARACTE
R_SET_RESULTS */;
/*!40101 SET
@OLD_COLLATION_CONNECTION=@@COLLATION
_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `votesystem`
--

-- --------------------------------------------------------

--
-- Table structure for table `admin`
--

CREATE TABLE `admin` (


`id` int(11) NOT NULL,
`username` varchar(50) NOT NULL,
`password` varchar(60) NOT NULL,
`firstname` varchar(50) NOT NULL,
`lastname` varchar(50) NOT NULL,
`photo` varchar(150) NOT NULL,
`created_on` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `admin`
--

INSERT INTO `admin` (`id`, `username`, `password`,


`firstname`, `lastname`, `photo`, `created_on`)
VALUES
(1, 'nurhodelta',
'$2y$10$fLK8s7ZDnM.1lE7XMP.J6OuPbQ.DPUVKBo
7rENnQY7gYq0xAzsKJy', 'Neovic', 'Devierte',
'facebook-profile-image.jpeg', '2018-04-02');

-- --------------------------------------------------------

--
-- Table structure for table `candidates`
--

CREATE TABLE `candidates` (


`id` int(11) NOT NULL,
`position_id` int(11) NOT NULL,
`firstname` varchar(30) NOT NULL,
`lastname` varchar(30) NOT NULL,
`photo` varchar(150) NOT NULL,
`platform` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `positions`
--

CREATE TABLE `positions` (


`id` int(11) NOT NULL,
`description` varchar(50) NOT NULL,
`max_vote` int(11) NOT NULL,
`priority` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `voters`
--

CREATE TABLE `voters` (


`id` int(11) NOT NULL,
`voters_id` varchar(15) NOT NULL,
`password` varchar(60) NOT NULL,
`firstname` varchar(30) NOT NULL,
`lastname` varchar(30) NOT NULL,
`photo` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `votes`
--

CREATE TABLE `votes` (


`id` int(11) NOT NULL,
`voters_id` int(11) NOT NULL,
`candidate_id` int(11) NOT NULL,
`position_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `admin`
--
ALTER TABLE `admin`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `candidates`
--
ALTER TABLE `candidates`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `positions`
--
ALTER TABLE `positions`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `voters`
--
ALTER TABLE `voters`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `votes`
--
ALTER TABLE `votes`
ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `admin`
--
ALTER TABLE `admin`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `candidates`
--
ALTER TABLE `candidates`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT=18;

--
-- AUTO_INCREMENT for table `positions`
--
ALTER TABLE `positions`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `voters`
--
ALTER TABLE `voters`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `votes`
--
ALTER TABLE `votes`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT=81;
COMMIT;
/*!40101 SET
CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET
_CLIENT */;
/*!40101 SET
CHARACTER_SET_RESULTS=@OLD_CHARACTER_SE
T_RESULTS */;
/*!40101 SET
COLLATION_CONNECTION=@OLD_COLLATION_CO
NNECTION */;

 ballot_modal.php

<!-- Preview -->


<div class="modal fade" id="preview_modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Vote Preview</h4>
</div>
<div class="modal-body">
<div id="preview_body"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
</div>
</div>
</div>
</div>

<!-- Platform -->


<div class="modal fade" id="platform">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><b><span
class="candidate"></b></h4>
</div>
<div class="modal-body">
<p id="plat_view"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
</div>
</div>
</div>
</div>

<!-- View Ballot -->


<div class="modal fade" id="view">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
<span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Your Votes</h4>
</div>
<div class="modal-body">
<?php
$id = $voter['id'];
$sql = "SELECT *, candidates.firstname AS
canfirst, candidates.lastname AS canlast FROM votes
LEFT JOIN candidates ON
candidates.id=votes.candidate_id LEFT JOIN positions
ON positions.id=votes.position_id WHERE voters_id =
'$id' ORDER BY positions.priority ASC";
$query = $conn->query($sql);
while($row = $query->fetch_assoc()){
echo "
<div class='row votelist'>
<span class='col-sm-4'><span class='pull-
right'><b>".$row['description']." :</b></span></span>
<span class='col-sm-8'>".$row['canfirst']." ".
$row['canlast']."</span>
</div>
";
}
?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default
btn-flat pull-left" data-dismiss="modal"><i class="fa fa-
close"></i> Close</button>
</div>
</div>
</div>
</div>

 conn.php

<?php
$conn = new mysqli('localhost', 'root', '',
'votesystem');

if ($conn->connect_error) {
die("Connection failed: " . $conn-
>connect_error);
}

?>

 footer.php

<footer class="main-footer">
<div class="container">
<div class="pull-right hidden-xs">
</div>
<strong>ONLINE VOTING MANAGMENT
SYSTEM</strong>
</div>
<!-- /.container -->
</footer>
 header.php

<!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/dataTa
bles.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:// -->
<!--[if lt IE 9]>
<script
src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shi
v.min.js"></script>
<script
src="https://oss.maxcdn.com/respond/1.4.2/respond.mi
n.js"></script>
<![endif]-->

<!-- Google Font -->


<link rel="stylesheet"
href="https://fonts.googleapis.com/css?
family=Source+Sans+Pro:300,400,600,700,300italic,400i
talic,600italic">

<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>

 navbar.php

<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="">
<img src="<?php echo (!
empty($voter['photo'])) ? 'images/'.$voter['photo'] :
'images/profile.jpg' ?>" class="user-image" alt="User
Image">
<span class="hidden-xs"><?php echo
$voter['firstname'].' '.$voter['lastname']; ?></span>
</a>
</li>
<li><a href="logout.php"><i class="fa fa-sign-
out"></i> LOGOUT</a></li>
</ul>
</div>
<!-- /.navbar-custom-menu -->
</div>
<!-- /.container-fluid -->
</nav>
</header>

 scripts.php

<!-- jQuery 3 -->


<script
src="bower_components/jquery/dist/jquery.min.js"></s
cript>
<!-- Bootstrap 3.3.7 -->
<script
src="bower_components/bootstrap/dist/js/bootstrap.m
in.js"></script>
<!-- iCheck 1.0.1 -->
<script src="plugins/iCheck/icheck.min.js"></script>
<!-- DataTables -->
<script
src="bower_components/datatables.net/js/jquery.data
Tables.min.js"></script>
<script
src="bower_components/datatables.net-bs/js/dataTabl
es.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script
src="bower_components/jquery-slimscroll/jquery.slimsc
roll.min.js"></script>
<!-- FastClick -->
<script
src="bower_components/fastclick/lib/fastclick.js"></scri
pt>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- Data Table Initialize -->
<script>
$(function () {
$('#example1').DataTable()
var bookTable = $('#booklist').DataTable({
'paging' : true,
'lengthChange': false,
'searching' : true,
'ordering' : true,
'info' : false,
'autoWidth' : false
})

$('#searchBox').on('keyup', function(){
bookTable.search(this.value).draw();
});

})
</script>

 session.php

<?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();
}

?>

 slugify.php

<?php

function slugify($string){
$preps = array('in', 'at', 'on', 'by', 'into', 'off', 'onto',
'from', 'to', 'with', 'a', 'an', 'the', 'using', 'for');
$pattern = '/\b(?:' . join('|', $preps) . ')\b/i';
$string = preg_replace($pattern, '', $string);
$string = preg_replace('~[^\\pL\d]+~u', '-', $string);
$string = trim($string, '-');
$string = iconv('utf-8', 'us-ascii//TRANSLIT', $string);
$string = strtolower($string);
$string = preg_replace('~[^-\w]+~', '', $string);

return $string;

}
?>

 home.php

<?php include 'includes/session.php'; ?>


<?php include 'includes/header.php'; ?>
<body class="hold-transition skin-blue layout-top-nav">
<div class="wrapper">

<?php include 'includes/navbar.php'; ?>

<div class="content-wrapper">
<div class="container">

<!-- Main content -->


<section class="content">
<?php
$parse = parse_ini_file('admin/config.ini',
FALSE, INI_SCANNER_RAW);
$title = $parse['election_title'];
?>
<h1 class="page-header text-center
title"><b><?php echo strtoupper($title); ?></b></h1>
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<?php
if(isset($_SESSION['error'])){
?>
<div class="alert alert-danger
alert-dismissible">
<button type="button"
class="close" data-dismiss="alert" aria-
hidden="true">&times;</button>
<ul>
<?php

foreach($_SESSION['error'] as $error){
echo "
<li>".
$error."</li>
";
}
?>
</ul>
</div>
<?php
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'>&times;</button>
<h4><i class='icon fa
fa-check'></i> Success!</h4>
".$_SESSION['success']."
</div>
";

unset($_SESSION['success']);
}

?>

<div class="alert alert-danger


alert-dismissible" id="alert" style="display:none;">
<button type="button" class="close"
data-dismiss="alert"
aria-hidden="true">&times;</button>
<span class="message"></span>
</div>

<?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{

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>
';
}

$instruct = ($row['max_vote'] > 1) ? 'You may select


up to '.$row['max_vote'].' candidates' : 'Select only one
candidate';

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>
';

$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>

<?php include 'includes/footer.php'; ?>


<?php include 'includes/ballot_modal.php'; ?>
</div>

<?php include 'includes/scripts.php'; ?>


<script>
$(function(){
$('.content').iCheck({
checkboxClass: 'icheckbox_flat-green',
radioClass: 'iradio_flat-green'
});

$(document).on('click', '.reset', function(e){


e.preventDefault();
var desc = $(this).data('desc');
$('.'+desc).iCheck('uncheck');
});

$(document).on('click', '.platform', function(e){


e.preventDefault();
$('#platform').modal('show');
var platform = $(this).data('platform');
var fullname = $(this).data('fullname');
$('.candidate').html(fullname);
$('#plat_view').html(platform);
});

$('#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>

 index.php

<?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>

<form action="login.php" method="POST">


<div class="form-group has-feedback">
<input type="text" class="form-control"
name="voter" placeholder="Voter's ID" required>
<span class="glyphicon glyphicon-user form-
control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" class="form-control"
name="password" placeholder="Password" required>
<span class="glyphicon glyphicon-lock form-
control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-4">
<button type="submit" class="btn
btn-primary btn-block btn-flat" name="login"><i
class="fa fa-sign-in"></i> Sign In</button>
</div>
<div class="col-xs-4 pull-right">
<a href="admin/index.php" class="btn btn-
primary btn-block btn-flat"><i class="fa fa-user"></i>
Admin</a>
</div>
</div>
</form>
</div>
<?php
if(isset($_SESSION['error'])){
echo "
<div class='callout callout-danger
text-center mt20'>
<p>".$_SESSION['error']."</p>
</div>
";
unset($_SESSION['error']);
}
?>
</div>

<?php include 'includes/scripts.php' ?>


</body>
</html>

 login.php

<?php
session_start();
include 'includes/conn.php';

if(isset($_POST['login'])){
$voter = $_POST['voter'];
$password = $_POST['password'];

$sql = "SELECT * FROM voters WHERE


voters_id = '$voter'";
$query = $conn->query($sql);

if($query->num_rows < 1){


$_SESSION['error'] = 'Cannot find voter
with the ID';
}
else{
$row = $query->fetch_assoc();
if(password_verify($password,
$row['password'])){
$_SESSION['voter'] = $row['id'];
}
else{
$_SESSION['error'] = 'Incorrect
password';
}
}

}
else{
$_SESSION['error'] = 'Input voter credentials
first';
}

header('location: index.php');

?>

 logout.php

<?php
session_start();
session_destroy();

header('location: index.php');
?>

 preview.php

<?php

include 'includes/session.php';
include 'includes/slugify.php';

$output = array('error'=>false,'list'=>'');

$sql = "SELECT * FROM positions";


$query = $conn->query($sql);

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>
<span class='col-sm-8'>".
$csrow['firstname']." ".$csrow['lastname']."</span>
</div>
";
}

echo json_encode($output);

?>

 submit_ballot.php
<?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')";
}

}
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');

?>
CHAPTER – 7

Operational Guide with Snapshots


Running guide

To run this project, you must have installed a virtual server


i.e; XAMPP on your PC.

Starting Apache and MySQL in XAMPP

So, for now, Open a browser and go to URL


http://localhost/phpmyadmin/
Databsae View

Home page
Admin view
Login page
Username: admin Password: password

After successful login


Dashboard
Votes

Voters

Positions
Candidates list

Ballot Position
Title

Users view

You might also like