-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlike.php
34 lines (29 loc) · 1.26 KB
/
like.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
include_once 'connect.php';
$is_liked = $_GET['is_liked'];
$post_id = $_GET['post_id'];
$username = $_GET['username'];
if($is_liked == 1){
$result = mysqli_query($conn, "DELETE
FROM likes
WHERE likername = '$username'
AND
post_id = $post_id "
);
$decrement_likes = mysqli_query($conn, "UPDATE posts
SET likes = likes-1
WHERE post_id = $post_id"
);
}else{
$result = mysqli_query($conn, " INSERT INTO
likes(post_id, likername)
values ($post_id, '$username')"
);
$increment_likes = mysqli_query($conn, "UPDATE posts
SET likes = likes+1
WHERE post_id = $post_id"
);
}
header("Location: feed.php?username=$username");
exit();
?>