forked from gopi1410/FEAT-V
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vote_presi.php
89 lines (83 loc) · 2.29 KB
/
vote_presi.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
<?php
session_start();
include('dbconnect.php');
//echo $_SERVER['REMOTE_ADDR'];
if($_SERVER['REMOTE_ADDR']!="::1") {
die("Invalid Access");
}
$apost="president";
$total=2;
$next="vote_sports";
$form="castvote_presi";
//No of checked radio buttons to be modified in validate
if($_SESSION['user']==1) {
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="myvote.js"></script>
</head>
<body>
<form method="POST" action="<?php echo $form; ?>.php">
<h1>President, Students' Gymkhana</h1>
<table cellspacing="10" align="center">
<?php
$idarr=array();
$namearr=array();
$sql="SELECT * FROM candidates WHERE post = '".$apost."' ORDER BY Name";
$result=mysql_query($sql) or die(mysql_error());
echo "<tr>";
while($row=mysql_fetch_assoc($result)) {
array_push($idarr, $row['id']);
array_push($namearr, $row['Name']);
echo '<td><img class="candpic" src="pics/'.$row['pic'].'" /></td>';
}
echo "</tr>";
echo '<tr align="center">';
foreach($namearr as $val) {
echo '<td><b>'.$val.'</b></td>';
}
echo '</tr>';
?>
<tr align="center">
<td>
<input type="radio" class="pref" name="pref1" value="<?php echo $idarr[0]; ?>" />Vote<br/>
</td>
<td>
<input type="radio" class="pref" name="pref1" value="<?php echo $idarr[1]; ?>" />Vote<br/>
</td>
</tr>
</table>
<script type="text/javascript">
$(document).ready(function() {
$('input[type="submit"]').on('click', function() {
sub = validate(<?php echo $total-1; ?>);
if(sub) {
$(this).prop('disabled', true);
this.form.submit();
}
else {
return false;
}
});
});
</script>
<div align="center">
<br/>
<input type="hidden" name="total" value="<?php echo $total; ?>" />
<input type="hidden" name="next" value="<?php echo $next; ?>" />
<input type="radio" id="pref0" name="pref0" value="<?php echo $apost; ?>" onclick="nopref()" />
No Preference<br/><br/>
<input type="submit" value="Cast My Vote" />
</div>
</form>
<audio id="sound" src="audio/beep-1.mp3"></audio>
</body>
</html>
<?php
}
else {
header('Location:index.php');
}
?>