-
Notifications
You must be signed in to change notification settings - Fork 0
/
registerUserToEvent.php
36 lines (29 loc) · 1014 Bytes
/
registerUserToEvent.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
require_once 'include/DB_Functions.php';
$db = new DB_Functions();
// json response array
$response = array("error" => FALSE);
if (isset($_POST['eID']) && isset($_POST['uID'])) {
// receiving the post params
$userID = $_POST['uID'];
$eventID = $_POST['eID'];
// create a new event
$confirm = $db->registerUserToEvent($userID, $eventID);
if ($confirm) {
// user registered to event
$response["error"] = FALSE;
$response["uid"] = $confirm["userID"];
$response["eid"] = $confirm["eventID"];
echo json_encode($response);
} else {
//user failed to register
$response["error"] = TRUE;
$response["error_msg"] = "User is already registered!";
echo json_encode($response);
}
} else {
$response["error"] = TRUE;
$response["error_msg"] = "Required parameters (name,age,email or password) is missing!";
echo json_encode($response);
}
?>