/
ajax_sendRequest.php
36 lines (26 loc) · 1002 Bytes
/
ajax_sendRequest.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
<?php
namespace src;
spl_autoload_register();
$user = new classes\User();
$user->onlyLoggedInUsers();
$user->setUsername($_SESSION['user']);
$currentlyLoggedIn = $user->showUser();
if (!empty($_POST)){
//new request
$f = new classes\Follow();
$f->setIsFollowing($_POST['isFollowing']);
$f->setIsFollower((int)$currentlyLoggedIn[0]['id']);//$_SESSION
$f->setStatus("pending");
$f->follow();
$response = [
"status" => "success",
"body" => htmlspecialchars($c->getIsFollowing()),
"post_Id" => htmlspecialchars($c->getIsFollower()),
"user" => htmlspecialchars($c->getStatus()),
"date" => htmlspecialchars(date("Y-m-d H:i:s")),
"message" => "Requested"
];
header('Content-Type: application/json');
echo json_encode($response);
}
?>