-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvoteupvote.php
34 lines (31 loc) · 899 Bytes
/
voteupvote.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
<?php
$servername="localhost";
$username="id14456134_root";
$password="[email protected]";
$database="id14456134_users";
$conn= mysqli_connect($servername,$username,$password,$database);
$name=$_GET['name'];
$topic=$_GET['topic'];
$upvote=$_GET['upvote'];
echo $upvote;
if($upvote==-1)
{
$sql="DELETE FROM `votes`
WHERE `id`='$name' AND `topic`='$topic';";
mysqli_query($conn,$sql);
$sql="UPDATE `topics`
SET `upvote`=`upvote`-1
WHERE `topic`='$topic' ;";
mysqli_query($conn,$sql);
}
else
{
$sql="INSERT INTO votes(`topic`,`id`,`vote`)
VALUES ('$topic','$name','$upvote');";
mysqli_query($conn,$sql);
$sql="UPDATE `topics`
SET `upvote`=`upvote`+1
WHERE `topic`='$topic' ;";
mysqli_query($conn,$sql);
}
?>