-
Notifications
You must be signed in to change notification settings - Fork 3
/
fallow_user.php
59 lines (33 loc) · 991 Bytes
/
fallow_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
<?php
session_start();
include("config.php");
if (isset($_POST['fallow'])) {
$user_id = $_SESSION['id'];
$falloing_person = $_POST['fallow_person'];
$sql = "INSERT INTO fallowing(User_ID, Other_user_id) VALUES ($user_id, $falloing_person);";
$stmt = $conn->prepare($sql);
$stmt->execute();
$conn->close();
update_Fallowers($falloing_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();
}
?>