-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccept_friend.php
More file actions
17 lines (17 loc) · 788 Bytes
/
accept_friend.php
File metadata and controls
17 lines (17 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?
require_once('./db_connect.inc');
session_start();
$query = "SELECT * FROM friends_relations WHERE user_id='".$_SESSION['user_id']."' AND friend_user_id='".$_REQUEST['id']."'";
$result = $db->query($query);
if($result->num_rows == 0) {
$query = "INSERT INTO friends_relations (user_id, friend_user_id) VALUES (".$_SESSION['user_id'].", ".$_REQUEST['id'].")";
$db->query($query);
$query = "INSERT INTO friends_relations (user_id, friend_user_id) VALUES (".$_REQUEST['id'].", ".$_SESSION['user_id'].")";
$db->query($query);
$query = "DELETE FROM friend_requests WHERE user_id='".$_SESSION['user_id']."' AND requesting_user_id='".$_REQUEST['id']."'";
$db->query($query);
header('location:./index.php?friends');
} else {
header('location:./index.php?members');
}
?>