48
1 DECLARATION: I Stephen Nganda Muindi declare to the best of research knowledge that this semester project is my original work and that it has never been submitted to any university or any other institution. The literature and citations from other people’s work have be en duly referenced and acknowledged in the text, footnotes and bibliography. Signed: …………………………………………………… Date…………………………………………………………… Stephen N. Muindi Student-JKUAT Signed: …………………………………………………… Date …………………………………………………………… Mr. Samson Ochingo Supervisor

Online Voting System

Embed Size (px)

DESCRIPTION

Its a project about an online voting system for colleges during their annual student organization elections

Citation preview

Page 1: Online Voting System

1

DECLARATION:

I Stephen Nganda Muindi declare to the best of research knowledge that this semester project is

my original work and that it has never been submitted to any university or any other institution.

The literature and citations from other people’s work have been duly referenced and

acknowledged in the text, footnotes and bibliography.

Signed: ……………………………………………………

Date……………………………………………………………

Stephen N. Muindi

Student-JKUAT

Signed: …………………………………………………… Date

……………………………………………………………

Mr. Samson Ochingo

Supervisor

Page 2: Online Voting System

2

DEDICATION

This project is dedicated to my Almighty God, my mother, to the department of computing in the

faculty of Institute of Computer Science and Information Technology (ICSIT) at Jomo Kenyatta

University of Agriculture and Technology (JKUAT) and to my fellow students who supported

and guided me throughout this worthy course of study.

Page 3: Online Voting System

3

ACKNOWLEDGEMENT

I register my appreciation and acknowledgement to the Almighty God for sustaining me, giving

me life, enabling me to finish this work through His strength, My mother (Ruth Muminah) and

my sister (Grace Ivui Muindi) for their moral and spiritual support, JKUAT for providing me

with such a conducive environment under which I could do my work and not forgetting my

supervisor Mr. Samson Ochingo for the technical support that he has offered unto me throughout

the entire process. My regards goes to all my classmates for the assistance and guidance that they

have offered unto me.

Page 4: Online Voting System

4

Declaration…………………………………………………………………………………1

Dedication………………………………………………………………………………….2

Acknowledgement………………………………………….……………………………....3

Introduction……………………………………………………………………………..…..6

Background………………………………………………………………………….....…6

Problem Statement………………………………………………………………………..6

Justification……………………………………………………………………………….Error!

Bookmark not defined.

Benefits of the new systems………………………………………………………………7

Objectives…………………………………………………………………………………7

Project Schedule……………………………………………………………………….....8

Literature Review……………………………………………………………………………9

Introduction……………………………………………………………………………...10

Case Study……………………………………………………………………………….10

Overview of the current Voting system in J.K.U.A.T………………...…………….10

System Analysis…………………………………………………………...………………..11

Introduction………………………………………………………………………………11

Problem Specification........................................................................................................12

Proposed System................................................................................................................13

Feasibility Study................................................................................................................14

Operational Feasibility................................................................................................14

Technical Feasibility...................................................................................................14

Economic Feasibility...................................................................................................15

Schedule Feasibility.....................................................................................................15

Requirements Specification................................................................................................16

Overview of System Requirements..............................................................................17

Functional Requirements……………………………………………………………..18

Non-Functional Requirements………………………………………………………...19

Page 5: Online Voting System

5

Data Collection Methods.....................................................................................................21

Questionnaires..............................................................................................................21

Interviews.....................................................................................................................22

Observation..................................................................................................................22

Documentation.............................................................................................................22

System Design........................................................................................................................23

Data Flow diagram…………………………………………………………………..23

Three Tier Architecture……………………………………………………………...24

Description of the Three Tier Architecture……………………………………….…24

System Interface and Design………………………………………………………………...26

Functional breakdown of the system by design………………………………………26

System Development…………………………………………………………….……….….30

Properties of programming languages and database used………………………………..30

PHP Programming Language……………………………………………………………..30

MYSQL Database…………………………………………………………………………31

XAMPP 1.7.2……………………………………………………………………………...31

Data Structures and Algorithms used………………………………………………………..33

Implementation and Testing…………………..………………………………………………38

Installation Guide…………………………………………………………………...….…38

Install the XAMPP server…………………………………………………………………38

Setting up the System……………………………………………………………………..44

Setting up the Database…………………………………………………………………...44

Accessing the System……………………………………………………………………..44

Risk associated with system…………………………………………………………………44

APPENDIX A: SAMPLE CODE .................................................................................. 45

APPENDIX B: REFERENCES ..................................................................................... 48

B.1 Webliograpy……………………………………………………………………………..48

B.1 Bibliography……………………………………………………………………………..48

Page 6: Online Voting System

6

CHAPTER ONE: INTRODUCTION

Background

Every academic year in J.K.U.A.T one of the most fundamental critical functions to the

student community takes place. The election of the student’s leaders is held at September of each

academic year in a bid to bring fresh ideas in the running of the student organization.

The methods of campaign, election and post-election processes have been all the same since

the inception of the student organization. These methods are in every right acceptable but fall

short in this age of information and Technology, in that they are slow, entertain rigging to some

degree and not so friendly to the environment.

Bearing in mind just but the few reasons outlined above, the need for a more fast and robust

election/voting system was idealized. Thus an online voting system.

Problem Statement

The major problem with the current system is that it involves a lot of manual operations which

are prone to errors and are definitely slow.

Limitations of the Current System

It is slow: the voting process has to be completed first before the results are announced

and also queuing to vote enhances the slowness

It is tedious: The clerks involved in the verification, tallying and other elections duties get

exhausted at the end of the day since everything is manual

The whole election process is not environment friendly since the amount of paper

required for that single day is humongous

The process is expensive, this is because a lot of paper has to be bought, ballot boxes, and

also the printing of the ballot papers

Rigging: Since the process of tallying the votes is manual unscrupulous clerks can tamper

with the results through rigging votes

Time wastage, due to the slowness of the system a lot of time is wasted in the whole

election process which could have been useful in undertaking other duties.

Page 7: Online Voting System

7

Justification

Web-based solutions can be accessed anywhere as long as there is connectivity. Bearing in mind

the expansive J.K.U.A.T intranet and the unlimited internet offered by the institution a web-

based election system would come in handy to facilitate free and fair elections.

The system would be centrally placed and only be active during the election period. The system

will incorporate verifications of students, voting for the candidates and a real-time tally of the

votes.

Since it is web-based it can be accessed from anywhere, be it at campus, in the hostels and even

at home.

Benefits of the new systems

The system will facilitate free and fair elections since the tallying of the votes

cannot be tampered with.

The system will facilitate a faster election process since one can vote from

anywhere and the real-time tallying makes it fast to announce the elected leaders.

Since the system removes the geographical limitation factor all students can vote

for their leader regardless of their location.

The election process is made cheaper since printing of ballot papers is eliminated

and fewer clerks if any required.

Cases of double voting are eliminated since the verification process of the system

ensures one cannot vote more than once.

Objectives

To develop an online web-based voting system that can be used during the

election period to vote for student leaders.

To come up with a system documentation

To establish the metrics for measuring and evaluating usability

To establish the principles that support usability

Page 8: Online Voting System

8

Project Schedule: The project will take one semester. Below is the breakdown of activities;

Task ID Week Task Name

1. 1-6 Research and proposal writing

2. 7-8 Data collection

3. 9-14 Project Design

4. 14-15 Documentation

5. 16 Presentation

Page 9: Online Voting System

9

CHAPTER TWO: LITERATURE REVIEW

Introduction

This section intends to review the current situation in the school which will assist in bettering the

voting system. Here we will look at the current methods and technologies used during voting as

well as the processes involved.

Case Study: Overview of the current Voting system in J.K.U.A.T

Currently in JKUAT elections are done in using the old age manual ballot system. A list of the

students vying for the Student Council has their names outlined so that the entire school can get

acquainted with them. After a week of campaigns the elections are done.

A list of all the students in JKUAT is availed to their respective departments. The different

departments set up polling stations in different parts of the school to facilitate the elections

process.

At the polling stations, students queue for a chance to vote a list of leaders in the different

positions. At the voting room a student is verified using their Student ID to ascertain that they are

genuine students of the campus. Their names’ are crossed off and each is given a ballot papers

where they check their candidates. Afterwards the votes are cast and the student leaves the room.

After the day is over, the tallying is done and depending on when its done, the results are

announced that day or the following morning.

However, one major issue that has not been exhaustively addressed so far is the security of

mobile applications. Security depends on several factors including sending and access to

confidential information via the client phones, how the information is protected, secured and the

level of user satisfaction in relation to reliability and dependability. The future of mobile

application heavily depends upon how secure the service is to use. Reliable and secure

applications play a central role in the success of mobile application.

Elections allow the populace to choose their representatives and express their preferences for

how they will be governed. Naturally, the integrity of the election process is fundamental to the

integrity of democracy itself. The election system must be sufficiently robust to withstand a

variety of fraudulent behaviors and must be sufficiently transparent and comprehensible that

voters and candidates can accept the results of an election. Unsurprisingly, history is littered with

examples of elections being manipulated in order to influence their outcome.

The design of a “good” voting system, whether electronic or using traditional paper ballots or

mechanical devices must satisfy a number of sometimes competing criteria. The anonymity of a

Page 10: Online Voting System

10

voter’s ballot must be preserved, both to guarantee the voter’s safety when voting against a

malevolent candidate, and to guarantee that voters have no evidence that proves which

candidates received their votes. The existence of such evidence would allow votes to be

purchased by a candidate. The voting system must also be tamper-resistant to a wide range of

attacks, including ballot stuffing by voters and incorrect tallying by insiders.

Page 11: Online Voting System

11

CHAPTER THREE: SYSTEM ANALYSIS

Introduction

When carrying out System Analysis of an Online voting system, the initial step is to find out

how the current/existing system works. This is to help in getting a better of understanding of the

problems that are existent and whether they can be fixed with the proposed system or whether

the existing system can be upgraded and modified. In short, system analysis is the process of

investigating a system, identifying problems, and using the information to recommend

improvements to the system. System analysis is supposed to define how the system will be

implemented.

Steps in System Analysis

Page 12: Online Voting System

12

In this section, we will focus our attention on the principal functional and non-functional

(performance) requirements of the Online voting System. These two types of requirements will

describe to us the capabilities of the system based on the objectives and goals, and what physical

software requirements are necessary for the system to work with ease.

There are 2 main phases that are involved in System Analysis:

Feasibility Study – used to check whether the project can be implemented i.e. is

practical

Requirements Specification – used to find out the capabilities of the system i.e.

what the system will be able to do, from as many sources as possible. Some of the

techniques that can be used to accomplish this task are interviews, document review,

focused group discussions and observation can be user to accomplish this task.

Problem Specification - Current System Analysis

After every year, a general election is held and the JKEC therefore is required to register voters

during this period. A manual system is used to carry out this process where the records of voters

are placed on paper. The process of voting takes a whole day in a specified polling stations,

voters spend unproductive hours (2-3 hours on average) queuing to vote. This makes the process

inconvenient as due to limitation of time and location, thereby reducing the voting rate and

anonymity. This is attributed to the unavailability of alternatives, complexity and general

uncertainty surrounding technological innovations. In the current system involves queuing at the

polling station of voter registration. As a result, the process has the following drawbacks:

Time consuming: Voters spend unproductive hours (2-3 hours on average) queuing to

vote.

Location limited: A voter can only vote at the polling station of registration.

Costly: A lot of paperwork involved in the current manual system which is costly and

the voter travelling costs.

Page 13: Online Voting System

13

Proposed System - Applicable Solutions

Development and implementation a secure system that will enable voting for the general public

are made easier, faster and at the user’s point of work. This is in terms of accessibility of the

service and the ease of its use. Voters will be able to vote from the point they are without need to

travel in advance.

There is a need to come up with a system that will not only help JKEC to improve its delivery of

services to voters but also to cut on the Government expenditure

The students registration process will be managed by the JKEC in collaboration with the

Department his/her course is offered. An administrator to update and manage the system will be

in charge of that stage of the registration process. The system will assist in ensuring that JKEC

has data on voters for use when need arises.

Voters’ data include:

Admission REG number.

Voter Identity.

Therefore e-voting not only serves as aid in counting the votes, by now they support all three main voting processes:

1. Pre-Election Phase: Identification of the voter, checking of eligibility

2. Election Phase: Casting the vote 3. Post-Election Phase: Counting of the votes.

The aim of this project is to develop a secure voting system with which users can participate using their mobile phone.

The system shall be made up of the following four components:

1. Web client application (e-vote) 2. Server application

3. Database back-end and web-based administration tool

The server should be able to send a reply to the client at real time, acknowledging the receiving

of the voter’s response.

In case of any delays like network traffic, the client party should be notified. This Proposal

allows a voter to cast his vote in a simple and convenient way without the limit of time and location, thereby increasing the voting rate, and also ensuring confidentiality and anonymity.

Keywords - Voting, web terminal (mobile phone), confidentiality, anonymity.

Page 14: Online Voting System

14

Feasibility Study

This is the measure of how beneficial or practical the development of an information system will

be to an organization. It is aimed at establishing whether it is worthwhile developing the new

system. This area introduces the system in terms of research into why it is more viable than the

existing system. Three main areas of feasibility study are identified: Operational Feasibility,

Technical Feasibility, Economical Feasibility and Schedule Feasibility. The following study was

carried out to establish whether the system development will carry on to the next stage:

a) Operational Feasibility

This is the measure of how well the solution of problems will work in the organization. It seeks

to answer the question: Is the problem worth solving? It is also a measure of how people feel

about the system project.

The system will save time for both voters and voting administrators. By use of their mobile

phones, voters will cast their votes. The voting exercise of voting can be done without

necessarily lining up in a polling station. This saves both time and cost.

b) Technical Feasibility

This is the measure of the practicality of a specific technical solution and the availability of

technical resources and expertise.

These recent advances in wireless and mobile communications have led to faster connection

speeds (currently at 384 kbps in 3G+), larger device screen size, and multiple modes of input and

new applications. These applications consist of software that runs on a mobile device and

performs tasks for the user of the mobile phone. Also known as downloadable, mobile

applications are common on most phones, including inexpensive, entry-level models. Their wide

use is due to the many functions they perform, including providing user interfaces for basic

telephony and messaging services as well as for advanced services such as games and videos. As

a result, there has been some serious interest in mobile applications and some progress has been

made in applications, framework, networking requirements, and business models.

Page 15: Online Voting System

15

c) Economic Feasibility

This is a measure of the cost effectiveness of a project or solution. It takes into account costs and

benefits. Thus it is often called Cost-Benefit Analysis.

A lot of paperwork involved in the current manual system which is costly and the voter

travelling costs.

Voters spend unproductive hours (2-3 hours on average) queuing to vote.

d) Schedule Feasibility

Schedule feasibility is a measure of how reasonable the project timetable is. It seeks to answer

the following question: ‘Given our technical expertise, are the project deadlines reasonable?’

Each phase of the system development should be done within a specific time frame to avoid

delays in the implementation and testing of the final product.

Page 16: Online Voting System

16

Requirement Specification

The process of requirements specification for a software product is very crucial since it plays a

great role towards the acceptability and the effectiveness of the developed software.

Requirements engineering is composed of:

• Requirements elicitation.

• Requirements analysis and negotiation.

• Requirements specification.

• System modeling.

• Requirements validation.

• Requirements management.

The study of the software product’s characteristics is very important since:

The relative importance of these characteristics depends on the product and the

environment in which it is to be used. In some cases, some attributes may dominate. The

deep study of the intended product exposes the key attributes of the system since this may

vary with regard to the system and its environment of use.

Costs tend to rise exponentially if very high levels of any one attribute are required. It is

therefore important to consider the feasibility of the system which is implied by the

ability of the stakeholders to facilitate the realization of such attributes.

Requirements engineering and analysis is however a very difficult task especially for large

projects. This is contributed by the fact that most users are not completely and clearly aware of

what they want in the system and this can be coupled with the volatility of the requirements. The

scope of the system may also be misunderstood that may lead to assumption of key components

of the system that would later call for reengineering the system which is costly in terms of

financial resources, labor and time.

The challenges encountered in requirements engineering inspired Somerville and Sawyer to

suggest a set of detailed guidelines for requirements elicitation. This includes:

• Assessing the business and technical feasibility for the proposed system.

Page 17: Online Voting System

17

• Identify the people who will help specify requirements and understand their organizational

bias.

• Define the technical environment into which the system or product will be placed.

• Identify the constraints that limit the functionality or performance of the system or product to

be built.

•A list of one or more requirements elicitation methods.

• Solicit participation from all stakeholders.

• Identify ambiguous requirements as candidates for prototyping.

• Create usage scenarios to help customers/users better identify key requirements.

The purpose of the proposed application is to allow users (votes) to vote using their mobile phones i.e. the aim of this project is to develop a secure voting system with which users can

Participate using their mobile phone.

Overview of System Requirements

Description of Information

The information required for the system includes:

The voter details – All the necessary information about the voter i.e. voter name, ID

number, registered SIMs, voter Security password and voting place identity information

e.g. county code, constituency code, ward code and polling station code.

The candidate details – All the necessary information about the candidate who is also a

voter i.e. ID number, political party, candidate photo, post vying.

Voting day details- voter details, candidates of choice, time casted.

Users of the Information

For the voting process the voter needs to identity is required i.e. ID number, voter

Security password.

Voter’s choice candidates are necessary for the voting process.

Page 18: Online Voting System

18

User Objectives

The following are some of the objectives that the voters would like to see from the system:

Convenient vote casting through the mobile phone.

Secure voting system.

User Access Restrictions

Administrator will access the details of the voters who have registered to vote via the phone.

Functional Requirements

This refers to the necessary tasks, action or activities that the system must accomplish, or enable

the user to do. The Online phone voting System is a secure mobile phone voting system with

which users can participate using their mobile phone.

The functional requirements of the system describe the functionality or services that the system

is expected to provide. In this case:

The system (mobile phone application- m-vote) will allow users to vote via their mobile

phones

Send a confirmation message to the voter that the voting process was successful e.g. time

when vote was cast.

The system shall provide appropriate error messages and users shall be accorded

sufficient help on how to carry on tasks e.g. In case of any delays like network traffic, the

voter should be notified.

Authentication -The system should identify each authorized voters every time they use

the system using a Student ID number.

The system shall impose a successful voter determination strategy in order to determine a

successful voter in order to avoid multi voting.

Make vote counting convenient.

Page 19: Online Voting System

19

Non-Functional Requirements

A non-functional requirement is a requirement that specifies criteria that can be used to judge the

operation of a system, rather than specific behaviors. The plan for implementing non-functional

requirements is detailed in the system architecture. Non-functional requirements define how a

system is supposed to be. Outlined below are some of the expectations of the system when

implemented:

a) Reliability

The Online voting system (e-vote) shall be robust enough to have a high degree of fault

tolerance. For example, if there is an invalid entry, the system should not crash and shall

identify the invalid input and produce a suitable error message.

The Online voting system shall be able to recover from hardware failures, power

The Online voting system shall impose a successful voter determination strategy in order

to determine a successful voter in order to avoid multi voting.

The Online voting system shall be available during the voting hours of the voting day.

Failures and other natural catastrophes should rollback the databases to their most recent

valid state.

b) Security

The system should implement strategies to counter hacking and access by unauthorized persons. The

application needs to be secure enough and should enable users to access it depending on the level of

the user. e.g. An administrator will be register voters, a authorized voter will only be allowed to vote.

The election system must be sufficiently robust to withstand a variety of fraudulent behaviors

and must be sufficiently transparent and comprehensible that voters and candidates can

accept the results of an election.

c) Performance

Response time of e-vote should be less than 5 seconds most of the time. Response time

refers to the time that the user should wait for before getting a response from the system

after querying it.

E-vote shall show no visible deterioration.

Page 20: Online Voting System

20

d) Integrity

Only the system administrator has the right to register voters. The system should be

physically and logically secure to protect the databases. The administrators need to be

authenticated before having access to the system

e) Scalability:

The system should be able to expand to meet future needs of the organization and still be

able to serve the purpose for which it was build.

f) Usability

Users should be able to understand the menu and options provided by the system.

The system shall provide an easy-to-use interface so that the users do not strain to interact

with the system.

Any notification or error messages generated by the system shall be clear, polite and free

of jargon.

The interface should be intuitive and easily navigable.

g) Availability and accessibility

The system should be up and running whenever needed.

h) Interoperability

The system should be able to work with other existing systems. It should ensure backward and

forward compatibility.

Page 21: Online Voting System

21

CHAPTER FOUR: DATA COLLECTION METHODS

These are the methods that were used to elicit requirements from the stakeholders of the system.

These stakeholders included:

Students i.e. voters

The candidates

JKEC (Jomo Kenyatta Electoral Commission)

The following is a brief description of the tools used to collect data from the various stakeholders

in order to establish requirements:

Questionnaires

A questionnaire is a method to collect data from the target users in a specific knowledge

domain. According to Peerce et al. Questionnaire is a well known technique to collect

demographic data and users’ opinions. The design of a questionnaire is important because it

addresses the research questions and hypothesis on which data is to be collected. The questions

can be closed or open ended.

The initial part in a questionnaire is mostly concern with demographical and experiential

information. This information could be used to find out the users’ experience with the current

system. Some of the major areas covered by the questionnaires were:

Shortcomings associated with the current mode of voting.

Views on online voting.

The proposed system.

Characteristics of a good output with regard to the system.

The questionnaires were administered to the students as well as the electoral commission. Fifty

(50) respondents were polled.

Page 22: Online Voting System

22

Interviews

Interviews are used to gain more insight into the user requirements. They involve having face to

face conversations with various stakeholders and getting to get more information. One advantage

of using interviews was that a participant's unique point of view can be explored in detail and

any point of misunderstanding was clarified.

These were administered on all the stakeholders. They interviews were open ended and semi-

structured. These were administered on all the stakeholders. They were mostly open-ended and

semi-structured to allow the users provide as much information as possible without feeling

pressured. One advantage of using interviews that a participant's unique point of view can be

explored in detail.

Observation

This involved observing the various stakeholders and their various roles they perform in the

process of voting. It was important in getting to know the problems that the clients mostly go

through in the process of voting. The main focus was on the students because the intended

software solution is aimed at making the process of voting more efficient and convenient for

them.

Documentation

Studying documentation involved studying the companies’ documented procedures for

transacting business. It involved studying the documents that have to be filled in, their contents

and the approval that is required to make a vote legally binding. It also involved getting to know

from JKEC what the necessary steps are in order for one to be eligible to vote and also eligible to

vie for a position.

Through the documentation, I was able to see what inputs were required for the process of voting

and the corresponding outputs.

Page 23: Online Voting System

23

CHAPTER FIVE: SYSTEM DESIGN

Data Flow diagram

Figure 1: Data Flow Diagram

Voting Process

Login

Registration

1. Chairperson

2. Vice-Chairperson

3. Secretary General

4. Finance Secretary

. . . . . . . . . . . . . . . . . .

Vote Tallying

RESULTS

Has voted?

YES

NO

STUDENT

VOTER

Not Registered

Registered

Page 24: Online Voting System

24

Three Tier Architecture

Figure 2: Three Tier Architecture

Description of the Three Tier Architecture

Presentation Tier

This layer presents data to the user and optionally permits data manipulation and data entry.

Web-based applications now often contain most of the data manipulation features. This is

accomplished through use of Dynamic HTML and client-side data sources and data cursors.

Logic Tier

Also referred to as the business logic tier, the middle tier. It controls an application’s

functionality by performing detailed processing. In this system tallying and checking whether

one has voted are processed at this level and the business functionalities are achieved at this

point.

Page 25: Online Voting System

25

Data Tier

This tier consists of database servers. This is where the project details are stored and they are

retrieved on request.

Page 26: Online Voting System

26

CHAPTER SIX: SYSTEM INTERFACE AND DESIGN

Most of the design is done on HTML 5 and jQuery libraries. Reason for choosing this was

because its easy and flexible to work with. HTML 5 being one of the latest technologies in web

programming provides more functionality than the previous.

Functional breakdown of the system by design

Login Page:

For anyone who is registered in the system, they provide the login details i.e Student Id no. , password

and choose their voter type (e.g Voter or Candidate).

The system verifies the credentials and logs into the system. If any of the log in details is wrong, an error

message is displayed.

Figure 3: Registering as a Voter

Registration:

For any student who is not registered as a voter/candidate, they register on this page. After registration the

persons are verified on whether they are students by the admin.

The registration link can be accessed at the login page:

Page 27: Online Voting System

27

Figure 4: Registering as a Voter

The registration page is active for a whole month before the elections, so that candidates and voters can

register and be verified. A week before elections the registration page cannot be accessed.

One can register as a voter or as a candidate:

Figure 5: Registering as a Voter

Figure 6: Registering as a Voter

Page 28: Online Voting System

28

Voting:

On successful log in, one can now do the voting.

The page is tabbed depending on the number of candidates to be voted for.

On this system there are 4 candidates to be voted for: Chairman, Vice Chairman, Entertainment Secretary

and Treasurer.

Figure 7: Voting For Chairperson

Page 29: Online Voting System

29

Figure 8: Voting For Vice Chairperson

Figure 9 :Voting for Treasurer

Figure 10: Voting for Entertainment Secretary

Page 30: Online Voting System

30

CHAPTER SEVEN: SYSTEM DEVELOPMENT

In the system analysis and design OOP (objects Oriented Programming) is used. The language

that is majorly in use on the server side is the PHP scripting language.

Properties of programming languages and database used

PHP Programming Language

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-

purpose scripting language that is especially suited for web development and can be embedded

into HTML.

There are three main areas where PHP scripts are used.

Server-side scripting. This is the most traditional and main target field for PHP. You need

three things to make this work. The PHP parser (CGI or server module), a web server and

a web browser. You need to run the web server, with a connected PHP installation. You

can access the PHP program output with a web browser, viewing the PHP page through

the server.

Command line scripting. You can make a PHP script to run it without any server or

browser. You only need the PHP parser to use it this way. This type of usage is ideal for

scripts regularly executed using cron (on *nix or Linux) or Task Scheduler (on

Windows).

Writing desktop applications. PHP is probably not the very best language to create a

desktop application with a graphical user interface, but if you know PHP very well, and

would like to use some advanced PHP features in your client-side applications you can

also use PHP-GTK to write such programs.

PHP can be used on all major operating systems, including Linux, many Unix variants (including

HP-UX, Solaris and OpenBSD), Microsoft Windows, Mac OS X, RISC OS, and probably others.

PHP has also support for most of the web servers today. This includes Apache, IIS, and many

others. And this includes any web server that can utilize the FastCGI PHP binary, like lighttpd

and nginx. PHP works as either a module, or as a CGI processor.

Page 31: Online Voting System

31

MYSQL Database

MySQL runs on more than 20 platforms including Linux, Windows, Mac OS, Solaris, IBM AIX,

giving you the kind of flexibility that puts you in control.

The MySQL database has become the world's most popular open source database because of its

high performance, high reliability and ease of use. It is also the database of choice for a new

generation of applications built on the LAMP stack (Linux, Apache, MySQL, PHP / Perl /

Python.) Many of the world's largest and fastest-growing organizations including Facebook,

Google, Adobe, Alcatel Lucent and Zappos rely on MySQL to save time and money powering

their high-volume Web sites, business-critical systems and packaged software.

Reason for use

Flexible

Open source

Panel to easily navigate in phpmyadmin

XAMPP 1.7.2

XAMPP is a full- featured AMPP (Apache MySQL, PHP, Perl) package that is one of the few

non-commercials AMPP middleware stacks available on Linux. With its tight integration,

XAMPP makes it possible to run anything from a personal home page to a full- featured

production site (though only for development purposes; XAMPP is not meant to be used on a

production server due to security issues).

XAMPP really shines in the following areas:

It is easy to install and set up.

It contains a number of useful packages that make it easy to do things like generate traffic

reports and accelerate PHP content.

It has been thoroughly tested on the SUSE, Red Hat, Mandrake, and Debian Linux

distributions, as well as on Windows® and Solaris.

Page 32: Online Voting System

32

XAMPP has various packages as stated below:

Basic packages

Basic packages include system, programming, and server software:

Apache, the famous Web server

MySQL, an excellent, free, open source database

PHP, the programming language

Perl, the programming language

ProFTPD, an FTP server

OpenSSL, for secure sockets layer support

Graphics packages

XAMPP includes the following graphics-related packages:

GD, the "Graphics Draw" library

libpng, the official PNG reference library

libjpeg, the official JPEG reference library

ncurses, the character graphics library

Database packages

And what would an integrated stack be without some database packages such as:

gdbm, the GNU implementation of the standard UNIX dbm library

SQLite, an extremely small, zero-configuration SQL database engine

FreeTDS, a database library that gives UNIX and Linux programs the ability to talk to

Microsoft SQL and Sybase databases

XML packages

For XML development, XAMPP includes the following:

Page 33: Online Voting System

33

expat, an XML parser library

Salbotron, an XML toolkit

libxml, an XML C parser and toolkit for GNOME

PHP packages

For PHP development, XAMPP includes the following:

PEAR, the PHP library

A pdf class that generates dynamic PDF documents with PHP

TURCK MMCache, a PHP performance enhancer

Data Structures and Algorithms used

Php code has very few data structures in the system. Although object oriented programing was

used to model the Candidate class:

<?php

include_once('php/dbconnector.php');

class Acandidate{

public $firstname=null;

public $secondname=null;

public $surname=null;

public $moto=null;

public $photo=null;

public $password=null;

public $memberType=null;

public $isVoted=null;

public $studentId=null;

Page 34: Online Voting System

34

public $position=null;

public function instantiate($id)

{

$sql="select * from voters where id='".trim($id)."'";

$result=mysql_query($sql);

if($row=mysql_fetch_object($result))

{

$this->firstname=$row->FirstName;

$this->secondname=$row->SecondName;

$this->surname=$row->SurName;

$this->moto=$row->Moto;

$this->photo=$row->Photo;

$this->password=$row->password;

$this->memberType=$row->memberType;

$this->hasVoted=$row->hasVoted;

}

}

public function update($id)

Page 35: Online Voting System

35

{

$sql="update voters set firstname='".$this->firstname."',

secondname='".$this->secondname."',

surname='".$this->surname."',

moto='".$this->moto."',

photo='".$this->photo."'

password='".$this->password."' where

id='".$id."'";

}

public function vInsert()

{

$sql="insert into

voters(firstname,secondname,surname,id,password,memberType) values('".trim($this-

>firstname)."','".trim($this->secondname)."','".trim($this->surname)."','".trim($this-

>studentId)."','".trim($this->password)."','".trim($this->memberType)."')";

//$state="1 Voter Added";

$query=mysql_query($sql);

if(!$query)

{

echo "Pole";

die('Error: '.mysql_error());

Page 36: Online Voting System

36

}

else

//echo $state;

//alert("You have been successfully Registered");

header('location:../project/index.php');

}

public function cInsert()

{$sql="insert into

voters(firstname,secondname,surname,id,Position,moto,Photo,password,memberType)

values('".trim($this->firstname)."','".trim($this->secondname)."','".trim($this-

>surname)."','".trim($this->studentId)."','".trim($this->position)."','".trim($this-

>moto)."','".trim($this->photo)."','".trim($this->password)."','".trim($this->memberType)."')";

//$state="1 Candidate Added";

$query=mysql_query($sql);

if(!$query)

{

echo "Pole ";

die('Error: '.mysql_error());

}

else

//echo $state;

//alert("You have been successfully Registered");

Page 37: Online Voting System

37

header('location:../project/index.php');

}

public function checkId($id)

{

$sql="select * from voters where id='".$id."'";

$result=mysql_query($sql);

if(mysql_num_rows($result)>0)

{

echo 'Student ID already in use!';

}

Else

echo'Student ID available!';

}

}

?>

Page 38: Online Voting System

38

CHAPTER EIGHT: IMPLEMENTATION AND TESTING

This is the second last stage in SDLC (Software Development Life cycle) the installation of the

software is done.

Installation Guide

The system runs on a server and does not have an .exe or Executable file. Below is the

installation process of the system and how it is setup:

Install the XAMPP server

Step One

XAMPP installs everything you need to run PHP pages and a MySQL database on your local

machine.

1. Double-click the Installer (.exe) file you downloaded from the XAMPP website.

2. The XAMPP installer asks you to specify the directory to install XAMPP. It is

recommended you leave the default setting specified.

3. Click Install.

Figure 11: Installation snap1

Page 39: Online Voting System

39

NOTE: The Installation process can take up to a few minutes. Once complete, a

Command Prompt window will display for you to configure a few additional settings.

The Command Prompt dialog will ask you some questions that you can answer by

choosing 'y' or 'n' on your keyboard.

4. You should answer each question using the default answer provided. The following

outlines each question, and the answer you should give.

o Should I add shortcuts to the startmenu/desktop?

Enter 'y' then Enter to add these shortcuts, otherwise hit the 'n' key on your

keyboard, then hit Enter.

o Should I locate the XAMPP paths correctly? Should I proceed?

Enter 'y' and then the Enter key.

o Should I make a portable XAMPP without drive letters?

Enter 'n' and then the Enter key.

o XAMPP is ready to use.

Hit the Enter key.

o I have set the timezone to...

Hit the Enter key.

5. Once you have answered all these questions, the following message will display.

Page 40: Online Voting System

40

Figure 12: Installation snap2

6. First, enter 5 to enable IPv4 only.

7. Lastly, enter 1 and hit Enter to open the XAMPP Control Panel.

Step 2: Start your Server

Once installed, you can use the XAMPP Control Panel to start your testing server.

1. Click Start next to both Apache and MySQL to start the services.

Starting these services can take a few seconds. When it is complete, ‘Running’ will display beside

each option.

Page 41: Online Voting System

41

Figure 13: Installation snap3

To make your testing server start automatically when your computer starts, you can check

the Svc checkbox beside both options.

NOTE: If the XAMPP Control Panel is not already running, go to C:\xampp\control.exe to open

the panel.

Step 3: A little cleanup

With your testing server now installed and running, there are a few final steps you should take to

make sure everything is configured to work perfectly.

1. Open a web browser such as Firefox or Internet Explorer.

Page 42: Online Voting System

42

2. In the address bar,enter http://localhost; You should see a XAMPP splash screen with

language options

3. Choose your preferred language; You should now see a confirmation window informing

you that ‘You have successfully installed XAMPP on your system’. This interface allows

you to configure certain XAMPP settings.

Security Settings

Best practices encourage you to always have a password specified for your MySQL

database, and we think you should too.

4. From the side navigation, choose Security.

Figure 14: Installation snap4

5. Click the link shown in the graphic below.

Figure 15: Installation snap5

Page 43: Online Voting System

43

The next page displays the login credentials for your MySQL database. The username

(SuperUser), 'root' is created for you automatically and is the username you can use for

accessing your MySQL database or creating a database connection.

6. In the new password field, enter a password for accessing your database.

7. Enter the password again in the second text field.

8. Choose Password Changing to confirm your new password.

You’ve now determined the username and password that you will use every time you

need to access your database, or create a database connection in Dreamweaver.

Each time you change your password, you will need to restart your testing server for the

change to take effect. Access the Control Panel by double-clicking the XAMPP icon in

your taskbar. Choose Stop and then Start beside the MySQL option to restart the

database.

Test the PHP Installation

Lastly, you should test your PHP Installation to make sure everything is set up for you to

load PHP pages on your local computer.

9. Navigate back to the http://localhost page you were at before.

10. Click the phpinfo() option from the side navigation.

Page 44: Online Voting System

44

Figure 16: Installation snap6

If you see a PHP page similar to this, you have completed setting up your PHP/MySQL

testing server.

Setting up the System

1 Copy all the files of the System from Evote/System Files to where xampp folder is

/xampp/htdocs/..

2 Navigate to php folder

3 Select Dbcon.php file and open

4 Change the username, Password of the database

5 Save the file

6 Navigate to data link

7 Change the username and the password of the variable as per your database

Setting up the Database 1. Open phpmyadmin by going to the URL http://localhost/phpmyadmin

2. Create a new database title evote

3. Import the database file(voters.sql) from the database folder in the Evote folder

Accessing the System

Open web browser (Mozilla, I.E)

Type URL http://localhost/eVote/

Risk associated with system

Uses CSS (Cascading Style Sheets) so may not be compatible with all Browsers.

Page 45: Online Voting System

45

APPENDIX A: SAMPLE CODE

Login Page:

Page 46: Online Voting System

46

Registration Page:

Voting Page:

Page 47: Online Voting System

47

Page 48: Online Voting System

48

APPENDIX B: REFERENCES

B.1 Webliograpy

W3Schools www.w3schools.com

B.2 Bibliography

Janet Valade, PHP and MySql for Dummies, 3rd Edition

Earle Castledine and Craig Sharkie, First Edition February 2010, JQuery from

Novice to Ninja

Rusell J.T Dyer ,MYSQL In A Nutshell (Page 3,14 ,40), 2nd Edition