-
Notifications
You must be signed in to change notification settings - Fork 0
/
registerUser.php
41 lines (34 loc) · 1.27 KB
/
registerUser.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
<?php
require_once 'include/DB_Functions.php';
$db = new DB_Functions();
// json response array
$response = array("error" => FALSE);
if (isset($_POST['uname']) && isset($_POST['uage']) && isset($_POST['uemailID'])&& isset($_POST['upwd'])) {
// receiving the post params
$fullName = $_POST['uname'];
$age = $_POST['uage'];
$emailID = $_POST['uemailID'];
$pwd = $_POST['upwd'];
// create a new event
$user = $db->addUser($fullName, $age, $emailID,$pwd);
if ($user) {
// user stored successfully
$response["error"] = FALSE;
$response["uid"] = $user["userID"];
$response["user"]["fullName"] = $user["fullName"];
$response["user"]["age"] = $user["age"];
$response["user"]["emailID"] = $user["emailID"];
$response["user"]["pwd"] = $user["pwd"];
echo json_encode($response);
} else {
// user failed to store
$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);
}
?>