-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.php
31 lines (31 loc) · 1.14 KB
/
sample.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
<?php
require 'vendor/autoload.php';
session_start();
if(!$_SESSION['user']){
header('Location:voting_index.php');
die();
}
$fileContents = file_get_contents("https://s3.ap-south-1.amazonaws.com/smart-contracts-blockchain/candidate_".$_SESSION['event_id'].".json");
$json = json_decode($fileContents, true);
$candidateList = $json['candidateDetails']['candidates'];
$candidateLength = $json['candidateDetails']['candidateLength'];
?>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
function voteForCandidate() {
candidateName = $("#candidate").val();
console.log(candidateName);
}
</script>
<form>
<select id="candidate" class="form-control myinput">
<?php
for($temp=0;$temp<$candidateLength;$temp++)
{
$temp2 = $temp +1;
echo"<option class=\"options\" value=\"candidate-".$temp2."\" >".$candidateList[$temp]."</option>";
}
?>
</select>
<input type="button" class="btn btn-primary btn-lg btn-block mybutton2" value="Vote" onclick="voteForCandidate()"/>
</form>