-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfriendsFunctions.php
More file actions
45 lines (38 loc) · 1.23 KB
/
friendsFunctions.php
File metadata and controls
45 lines (38 loc) · 1.23 KB
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
<?php
include_once 'db_credentials.php';
include_once 'sendEmail.php';
include_once 'utilityFunctions.php';
include_once 'classes.php';
function followUser($user, $follow) {
$connection = connectAccount();
$query = "INSERT INTO FriendTest (followerID, followedID) VALUES ('$user', '$follow')";
if(mysqli_query($connection, $query)) {
$message = "SUCCUser $follow has been successfully followed!\n\n";
sendMessage($message, $sock);
}
else {
$message = "FAILSomething went wrong.\n\n";
sendMessage($message, $sock);
}
disconnect($connection);
}
function searchUser($user, $sock) {
$connection = connectAccount();
$query = "SELECT Username FROM UserInfo WHERE Username LIKE '%$user%' ORDER BY Username ASC LIMIT 20";
if(mysqli_query($connection, $query)) {
echo "Yeeeeeeeee buddy it worked!\n\n";
$result = mysqli_query($connection, $query);
$searchResults = "";
while ($rows = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$searchResults .= $rows["Username"] . " ";
}
$message = "RSLT$searchResults";
sendMessage($message, $sock);
}
else {
echo "Damn it didn't work son :/ ... Error: " . mysqli_error($connection);
$message = "FAIL";
}
disconnect($connection);
}
?>