forked from dbakti7/Parkin-App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_user.php
71 lines (56 loc) · 1.82 KB
/
read_user.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/*
* Following code will get single user details
* A product is identified by username (user_name)
*/
// array for JSON response
$response = array();
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
// check for post data
if (isset($_GET["user_name"])) {
$user_name = $_GET['user_name'];
// get a product from products table
$result = mysql_query("SELECT *FROM userlogin WHERE user_name = $user_name");
if (!empty($result)) {
// check for empty result
if (mysql_num_rows($result) > 0) {
$result = mysql_fetch_array($result);
$user = array();
$user["id"] = $result["id"];
$user["user_name"] = $result["user_name"];
$user["name"] = $result["name"];
$user["email"] = $result["email"];
$user["phone_number"] = $result["phone_number"];
$user["password"] = $result["password"];
// success
$response["success"] = 1;
// user node
$response["user"] = array();
array_push($response["user"], $user);
// echoing JSON response
echo json_encode($response);
} else {
// no product found
$response["success"] = 0;
$response["message"] = "No user found";
// echo no users JSON
echo json_encode($response);
}
} else {
// no product found
$response["success"] = 0;
$response["message"] = "No user found";
// echo no users JSON
echo json_encode($response);
}
} else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
?>