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