-
Notifications
You must be signed in to change notification settings - Fork 1
/
unfollow.php
45 lines (38 loc) · 2.12 KB
/
unfollow.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
<?php
include_once 'connect.php';
$follower = $_GET['follower'];
$unfollowing = $_GET['unfollowing'];
$return = $_GET['return'];
if($return == 'explore'){
$for_us = $_GET['for'];
$get = $_GET['get'];
}
$remove_relation = mysqli_query ($conn, "DELETE FROM followings
WHERE username = '$follower'
AND
following = '$unfollowing' "
);
if($remove_relation){
$decrement_follower = mysqli_query ($conn, " UPDATE users
SET followers = CASE
WHEN followers > 0
THEN followers - 1
ELSE 0
END
WHERE username = '$unfollowing'"
);
$decrement_following = mysqli_query ($conn, " UPDATE users
SET followings = CASE
WHEN followings > 0
THEN followings - 1
ELSE 0
END
WHERE username = '$follower'"
);
}
if($return == 'profile')
header("Location: profile.php?curr_us=$follower&profile_for=$unfollowing");
else if($return == 'explore')
header("Location: explore.php?curr=$follower&for=$for_us&get=$get");
exit();
?>