-
Notifications
You must be signed in to change notification settings - Fork 3
/
Unfollow_User.php
67 lines (40 loc) · 1.16 KB
/
Unfollow_User.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
session_start();
include("config.php");
if (isset($_POST['unfollow']))
{
$user_id = $_SESSION['id'];
$unfollow_person = $_POST['other_User_Id'];
$get_Id = "SELECT * FROM fallowing WHERE User_Id = $user_id AND Other_user_id = $unfollow_person;";
$data = mysqli_query($conn, $get_Id);
while($row = mysqli_fetch_assoc($data))
{
$target_id = $row['ID'];
}
$sql = "DELETE FROM fallowing WHERE ID = $target_id;";
$stmt = $conn->prepare($sql);
$stmt->execute();
$conn->close();
update_Fallowers($unfollow_person);
update_Fallowing($user_id);
$_SESSION['fallowing'] = $_SESSION['fallowing']-1;
header("location: home.php");
}
else{
header("location: home.php");
}
function update_Fallowing($user_id)
{
include("config.php");
$sql = "UPDATE users SET FALLOWING = FALLOWING-1 WHERE User_ID = $user_id ;";
$stmt = $conn -> prepare($sql);
$stmt->execute();
}
function update_Fallowers($other_Person)
{
include("config.php");
$sql = "UPDATE users SET FALLOWERS = FALLOWERS-1 WHERE User_ID = $other_Person;";
$stmt = $conn -> prepare($sql);
$stmt->execute();
}
?>