-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetdetails.php
49 lines (39 loc) · 1.29 KB
/
getdetails.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
<?php
session_start();
include 'inc/checker.php';
include 'inc/config.php';
$pollid=$_GET['pollid'];
$userid=$_GET['userid'];
if($_SESSION['polllog']==true && $userid && $userid==$_SESSION['polluserid'])
{
echo "[";
if($pollid)
{
$query=$db->query("SELECT * FROM ".$subscript."polls WHERE pollid='$pollid'");
if($db->numrows($query)>0){
$result=$db->fetch($query);
// First printing the main details :
$totalvotes=$db->numrows($db->query("SELECT * FROM ".$subscript."pollvotes WHERE pollid='$pollid'"));
echo "{";
echo '"title":"'.$result['title']."\",";
echo '"options":'.$result['options'].",";
echo '"totalvotes":'.$totalvotes.",";
echo '"date_created":"'.$result['date_created'].'",';
echo '"last_updated":"'.$result['updated'].'"';
echo "},";
// Now the voting results.
$query1=$db->query("SELECT * FROM ".$subscript."pollvotes WHERE userid='$userid' AND pollid='$pollid'");
if($db->numrows($query1)!=0){
$vote=$db->fetch($query1);
echo "{\"uservote\":".$vote['voteindex']."}";
}
else{
echo "{\"uservote\":-1}";
}
}
}
echo "]";
}else{
echo "Unauthorised.";
}
?>