-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddClick.php
52 lines (37 loc) · 1.03 KB
/
addClick.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* @author Taha
*/
require_once 'include/DB_Functions_Event.php';
$db = new DB_Functions_Event();
// json response array
$response = array("error" => FALSE);
if(!isset($_POST['ad_id'])){
$response["ad_id"] = "missing";
}
if(!isset($_POST['user_id'])){
$response["user"] = "missing";
}
if (isset($_POST['ad_id']) && isset($_POST['user_id'])) {
// receiving the post params
$ad = $_POST['ad_id'];
$user = $_POST['user_id'];
// create a new interest
$click = $db->addClick($ad, $user);
if ($click) {
$response["error"] = FALSE;
echo json_encode($response);
} else {
// event failed to store
$response["error"] = TRUE;
$response["error_msg"] = "Unknown error occurred in storing interest!";
/*db->storeTestEvent();*/
echo json_encode($response);
}
} else {
$response["error"] = TRUE;
$response["error_msg"] = "Required parameters are missing!";
/*db->storeTestEvent();*/
echo json_encode($response);
}
?>