-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_user_details.php
More file actions
45 lines (37 loc) · 1.48 KB
/
get_user_details.php
File metadata and controls
45 lines (37 loc) · 1.48 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
<?php
require_once '/home/u332930526/public_html/android_api/include/DB_Functions.php';
$db = new DB_Functions();
// json response array
$response = array("error" => FALSE);
if (isset($_POST['username']) && isset($_POST['password'])) {
// receiving the post params
$username = $_POST['username'];
$password = $_POST['password'];
// get the user by username and password
$user = $db->getUserByUsernameAndPassword($username, $password);
if ($user != false) {
// use is found
$response["error"] = FALSE;
$response["uid"] = $user["unique_id"];
$response["user"]["name"] = $user["name"];
$response["user"]["username"] = $user["username"];
$response["user"]["previllage"] = $user["previllage"];
$response["user"]["created_at"] = $user["created_at"];
$response["user"]["updated_at"] = $user["updated_at"];
//response sending image
$img_string = $db->convertImageToBase64($user["image"]);
$response["user"]["image"] = $img_string;
echo json_encode($response);
} else {
// user is not found with the credentials
$response["error"] = TRUE;
$response["error_msg"] = "Login credentials are wrong. Please try again!";
echo json_encode($response);
}
} else {
// required post params is missing
$response["error"] = TRUE;
$response["error_msg"] = "Required parameters username or password is missing!";
echo json_encode($response);
}
?>