-
Notifications
You must be signed in to change notification settings - Fork 0
/
friends.php
32 lines (32 loc) · 1.12 KB
/
friends.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
<!DOCTYPE html>
<html>
<head>
<meta charset-"utf-8" />
<link rel="stylesheet" href="style.css" media="screen" type="text/css" />
<title>Vos amis</title>
</head>
<body>
<?php
$conn = new PDO('mysql:host=localhost;dbname=chat_base', 'root', '');
$user_id = $_POST['user_id'];
include('top_button.php');
?>
Vos amis :<br/><br/>
<form action="send_friend_request.php?admin=0" method="post">
<input type = "hidden" name = "user_id" value = <?php echo $_POST['user_id'] ?>></input>
<input type = "hidden" name = "friend_name" value = ""></input>
<input type = "hidden" name = "error" value = ""></input>
<input type = "submit" value = "Ajouter un ami"/>
</form>
<?php
$sql_friends = "SELECT U.* FROM users U WHERE U.user_id IN
(SELECT user1_id from friends where user2_id = $user_id AND user_didnt_accepted_id = 0 UNION
SELECT user2_id from friends where user1_id = $user_id AND user_didnt_accepted_id = 0)";
$friends = $conn->query($sql_friends);
while ($friend_array = $friends->fetch()) {
echo $friend_array['name'];
echo nl2br ("\n");
}
?>
</body>
</html>