forked from Puneet2000/Edhub-php-server-script-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetlike.php
More file actions
40 lines (28 loc) · 875 Bytes
/
setlike.php
File metadata and controls
40 lines (28 loc) · 875 Bytes
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
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "student_information";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$user_name=$_GET["username"];
$solutionid=$_GET["solutionid"];
$ischecked=$_GET["ischecked"];
if($ischecked=="Uncheck")
{$mysql_qry="delete FROM Likes WHERE Username LIKE '$user_name' AND SolutionID LIKE '$solutionid';";
$conn->query("update solutions set Likes=Likes-1 where SolutionID LIKE '$solutionid';");
}
else if($ischecked=="Check")
{$mysql_qry="insert into Likes (Username,SolutionID) values('$user_name' , '$solutionid');";
$conn->query("update solutions set Likes=Likes+1 where SolutionID LIKE '$solutionid';");
}
$result= $conn->query($mysql_qry);
if( $result==true )
{
echo "Success";
}
else
{
echo "Unsuccess";
}
?>