-
Notifications
You must be signed in to change notification settings - Fork 0
/
rewardcheck2.php
60 lines (45 loc) · 1.33 KB
/
rewardcheck2.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
<?php
include("database_connect.php");
$range = 0;
if(!isset($_SESSION))
{
session_start();
}
$uid=$_SESSION["userid"];
$sql="select count(voteId) as count from votes where userId=$uid";
$sql2="select * from reward where type='vote' "; //retrieve data from system storage
include("database_connect.php"); //provide database connection
$result=mysqli_query($con,$sql);
$result2=mysqli_query($con,$sql2);
if ($row=mysqli_fetch_array($result))
{
$count=$row["count"];
//echo $count;
}
while($row2 = mysqli_fetch_array($result2))//retrieve data one by one
{
// echo "here";
if(($count+1)==$row2["postcount"])
{
// echo "also here";
$range=$row2["postcount"];
// echo $range;
}
}
if($range!=0)
{
$sql3="select level from reward where postcount='$range' and type='vote'";
$result3=mysqli_query($con,$sql3);
while($row3=mysqli_fetch_array($result3))
{
$level=$row3["level"];
// echo $level;
$sql4="update register set reward2=$level where id=$uid";
if(mysqli_query($con,$sql4))
{
$s = "....Congratulations.... \\n You Have been Rewarded for voting";
echo "<script>alert(\"$s\")</script>";
}
}
}
?>