-
Notifications
You must be signed in to change notification settings - Fork 0
/
vote2.php
254 lines (192 loc) · 6.58 KB
/
vote2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<?php
include('session.php');
include('dbcon.php');
include('header.php');
?>
<?php
if (isset($_POST['vote'])){
$gov=$_POST['gov'];
mysqli_query($conn,"insert into votes (CandidateID)values('$gov')")or die(mysqli_error());
$vice=$_POST['vice'];
mysqli_query($conn,"insert into votes (CandidateID)values('$vice')")or die(mysqli_error());
$rep1=$_POST['rep1'];
mysqli_query($conn,"insert into votes (CandidateID)values('$rep1')")or die(mysqli_error());
$rep2=$_POST['rep2'];
mysqli_query($conn,"insert into votes (CandidateID)values('$rep2')")or die(mysqli_error());
$rep3=$_POST['rep3'];
mysqli_query($conn,"insert into votes (CandidateID)values('$rep3')")or die(mysqli_error());
mysqli_query($conn,"update voters set Status='Voted' where VoterID='$session_id'") or die(mysqli_error());
_redirect('thankyou.php');
}
?>
<link rel="stylesheet" type="text/css" href="admin/css/style.css" />
<script src="jquery.iphone-switch.js" type="text/javascript"></script>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand">
<img src="admin/images/logo.jpg" width="60" height="60">
</a>
<a class="brand">
<h2>ONLINE VOTING SYSTEM</h2>
<div class="chmsc_nav"><font size="4" color="white">CU</font></div>
</a>
<?php include('head.php'); ?>
</div>
</div>
</div>
<div class="wrapper">
<div class="hero-body-voting">
<div class="vote_wise1"><font color="white" size="6">"Official Ballot"</font></div>
<div class="back">
<a class="btn btn-info" id="bak" href="voting2.php"><i class="icon-arrow-left icon-large"></i> Back</a>
</div>
</div>
<div class="hero-body-456">
</div>
<form method="POST">
<?php
if (isset($_POST['save'])){
$governor=$_POST['governor'];
$vice1=$_POST['vice'];
$representative1=$_POST['representative1'];
$representative2=$_POST['representative2'];
$representative3=$_POST['representative3'];
if($representative1=='--Select Candidate--' && $representative2=='--Select Candidate--' && $representative3=='--Select Candidate--'){
echo '';
}
if($representative1=='--Select Candidate--' && $representative3=='--Select Candidate--' ){
echo '';
}else if($representative2=='--Select Candidate--' && $representative3=='--Select Candidate--' ){
echo '';
}else if($representative1=='--Select Candidate--' && $representative2=='--Select Candidate--' ){
echo '';
}
else if($representative1==$representative2 || $representative1==$representative3){
?>
<script type="text/javascript">
alert('Same Representative is not aloud');
window.location="voting.php";
</script>
<?php
}
else if($representative2==$representative1 || $representative2==$representative3
){
?>
<script type="text/javascript">
alert('Same Representative is not aloud');
window.location="voting.php";
</script>
<?php
}
else if($representative3==$representative1 || $representative3==$representative2
){
?>
<script type="text/javascript">
alert('Same Representative is not aloud');
window.location="voting.php";
</script>
<?php
}
}
//governor
$result=mysqli_query($conn,"select * from candidate where CandidateID='$governor'")or die(mysqli_query($conn,));
$row=mysqli_fetch_array($result);
$name=$row['FirstName']." ".$row['LastName'];
//
//vice-governor
$vice=mysqli_query($conn,"select * from candidate where CandidateID='$vice1'")or die(mysqli_query($conn,));
$row_vice=mysqli_fetch_array($vice);
$name1=$row_vice['FirstName']." ".$row_vice['LastName'];
//
//Representative1
$Representative1=mysqli_query($conn,"select * from candidate where CandidateID='$representative1'")or die(mysqli_query($conn,));
$Representative1_row=mysqli_fetch_array($Representative1);
$name2=$Representative1_row['FirstName']." ".$Representative1_row['LastName'];
//
//Representative2
$Representative2=mysqli_query($conn,"select * from candidate where CandidateID='$representative2'")or die(mysqli_query($conn,));
$Representative2_row=mysqli_fetch_array($Representative2);
$name3=$Representative2_row['FirstName']." ".$Representative2_row['LastName'];
//
//Representative3
$Representative3=mysqli_query($conn,"select * from candidate where CandidateID='$representative3'")or die(mysqli_query($conn,));
$Representative3_row=mysqli_fetch_array($Representative3);
$name4=$Representative3_row['FirstName']." ".$Representative3_row['LastName'];
//
?>
<div class="ballot">
<div class="cent">
<p>Governor: </p>
<?php echo $name;
if ($governor == "--Select Candidate--"){
echo 'NO Candidate Selected';
}
?>
<input type="hidden" name="gov" value="<?php echo $governor; ?>"/>
</div>
</br>
</br>
<div class="cent">
<p>Vice-Governor: </p>
<?php echo $name1;
if ($vice1 == "--Select Candidate--"){
echo 'NO Candidate Selected';
}
?>
<input type="hidden" name="vice" value="<?php echo $vice1; ?>"/>
</div>
</br>
</br>
<div class="cent">
<p>1st Year Representative: </p>
<div class="rep2">
<?php ?>
<?php
if ($representative1=='--Select Candidate--' && $representative2=='--Select Candidate--' && $representative3=='--Select Candidate--'){
echo 'No Candidate Selected';
}else{
echo $name2;
}
?>
<input type="hidden" name="rep1" value="<?php echo $representative1; ?>"/>
</div>
<div class="rep2">
<?php echo $name3; ?>
<input type="hidden" name="rep2" value="<?php echo $representative2; ?>"/>
</div>
<div class="rep2">
<?php echo $name4; ?>
<input type="hidden" name="rep3" value="<?php echo $representative3; ?>"/>
</div>
</div>
</div>
<div class="hero-body-456">
<div class="ok_vote">
<a class="btn btn-success" id="logout" data-toggle="modal" href="#myModal"><i class="icon-off"></i> Submit Final Votes</a>
<div class="modal hide fade" id="myModal">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">�</button>
<h3> </h3>
</div>
<div class="modal-body">
<p><font color="gray">Are You Sure you Want to Submit Final Votes?</font></p>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">No</a>
<button id="save_voter" class="btn btn-success" name="vote"><i class="icon-save icon-large"></i> Yes</button>
</div>
</div>
</div>
</div>
</form>
<?php include('footer1.php')?>
</div>
</body>
</html>