-
Notifications
You must be signed in to change notification settings - Fork 45
/
unfollow.php
34 lines (34 loc) · 854 Bytes
/
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
<?php
session_start();
$user_id = $_SESSION['user_id'];
?>
<?php
if($_GET['userid'] && $_GET['username']){
if($_GET['userid']!=$user_id){
$unfollow_userid = $_GET['userid'];
$unfollow_username = $_GET['username'];
include 'connect.php';
$query = mysql_query("SELECT id
FROM following
WHERE user1_id='$user_id' AND user2_id='$unfollow_userid'
");
mysql_close($conn);
if(mysql_num_rows($query)>=1){
include 'connect.php';
mysql_query("DELETE FROM following
WHERE user1_id='$user_id' AND user2_id='$unfollow_userid'
");
mysql_query("UPDATE users
SET following = following - 1
WHERE id='$user_id'
");
mysql_query("UPDATE users
SET followers = followers - 1
WHERE id='$unfollow_userid'
");
mysql_close($conn);
}
header("Location: ./".$unfollow_username);
}
}
?>