File: //proc/thread-self/cwd/service.php 11-5-2018
<?php
/*
* Following code will get single department details
* A industry is identified by dept_id
*/
// array for JSON response
$response = array();
// include db connect class
require_once 'db_connect.php';
// connecting to db
$db = new DB_CONNECT();
// check for post data
if (isset($_GET["dept_id"])) {
$dept_id = $_GET['dept_id'];
// get a deptId from beatle_industry table
$result = mysql_query("SELECT * FROM beatle_industry WHERE db_IndLoginId LIKE '$dept_id'")or die(mysql_error());
if (!empty($result)) {
// check for empty result
if (mysql_num_rows($result) > 0) {
$result = mysql_fetch_array($result);
$deptDetail = array();
$deptDetail["dept_id"] = $result["db_IndLoginId"];
$deptDetail["ind_id"] = $result["IndId"];
$deptDetail["ind_name"] = $result["db_industry"];
$deptDetail["branch_id"] = $result["db_bracnchid"];
$deptDetail["keyword"] = $result["keywordName"];
// success
$response["success"] = 1;
// user node
$response["deptDetail"] = array();
array_push($response["deptDetail"], $deptDetail);
// echoing JSON response
echo json_encode($response);
} else {
// no product found
$response["success"] = 0;
$response["message"] = "No product found..";
// echo no users JSON
echo json_encode($response);
}
} else {
// no industry found
$response["success"] = 0;
$response["message"] = "No product found.";
// echo no users JSON
echo json_encode($response);
}
}else if (isset($_GET["phoneno"],$_GET["pass"])) {
$phoneno = $_GET['phoneno'];
$password = $_GET['pass'];
$pass = md5($password);
// get a deptId from beatle_industry table
$result = mysql_query("SELECT * FROM beatle_userlogin WHERE db_phone LIKE '$phoneno' AND db_password LIKE '$pass'")or die(mysql_error());
$result2 = mysql_query("SELECT * FROM beatle_userlogin WHERE db_userLoginName LIKE '$phoneno' AND db_password LIKE '$pass'")or die(mysql_error());
if (!empty($result)) {
// check for empty result
if (mysql_num_rows($result) > 0) {
$result = mysql_fetch_array($result);
$userDetail = array();
$userDetail["userid"] = $result["userId"];
$userDetail["db_phone"] = $result["db_phone"];
$userDetail["userLoginName"] = $result["db_userLoginName"];
$userDetail["username"] = $result["db_username"];
$userDetail["password"] = $result["db_password"];
$userDetail["usertype"] = $result["db_usertype"];
$userDetail["orgID"] = $result["OrgID"];
$userDetail["branchID"] = $result["BranchID"];
$userDetail["industryID"] = $result["IndustryID"];
// success
$response["success"] = 1;
// user node
$response["userDetail"] = array();
array_push($response["userDetail"], $userDetail);
// echoing JSON response
echo json_encode($response);
} else {
// no product found
//$response["success"] = 0;
//$response["message"] = "No product found..";
// echo no users JSON
//echo json_encode($response);
if (!empty($result2)) {
if (mysql_num_rows($result2) > 0) {
$result = mysql_fetch_array($result2);
$userDetail = array();
$userDetail["userid"] = $result["userId"];
$userDetail["db_phone"] = $result["db_phone"];
$userDetail["userLoginName"] = $result["db_userLoginName"];
$userDetail["username"] = $result["db_username"];
$userDetail["password"] = $result["db_password"];
$userDetail["usertype"] = $result["db_usertype"];
$userDetail["orgID"] = $result["OrgID"];
$userDetail["branchID"] = $result["BranchID"];
$userDetail["industryID"] = $result["IndustryID"];
// success
$response["success"] = 1;
// user node
$response["userDetail"] = array();
array_push($response["userDetail"], $userDetail);
// echoing JSON response
echo json_encode($response);
}else {
// no industry found
$response["success"] = 0;
$response["message"] = "No user found...";
// echo no users JSON
echo json_encode($response);
}
}
}
} else {
// no industry found
$response["success"] = 0;
$response["message"] = "No user found.";
// echo no users JSON
echo json_encode($response);
}
}else if (isset($_GET["user_id"])) {
$user_id = $_GET['user_id'];
// get a deptId from beatle_industry table
$result = mysql_query("SELECT * FROM beatle_userlogin WHERE userId LIKE '$user_id' ")or die(mysql_error());
if (!empty($result)) {
// check for empty result
if (mysql_num_rows($result) > 0) {
$result = mysql_fetch_array($result);
$city = '';
$state ='';
$rescity = mysql_query("SELECT name FROM cities WHERE id LIKE ".$result["db_city"]." ")or die(mysql_error());
if (!empty($rescity)) {
$row = mysql_fetch_row($rescity);
$test = $row[0];
$city = $test;
}
$restate = mysql_query("SELECT name FROM states WHERE id LIKE ".$result["db_state"]." ")or die(mysql_error());
if (!empty($restate)) {
$row = mysql_fetch_row($restate);
$test = $row[0];
$state = $test;
}
$userDetail = array();
$userDetail["userid"] = $result["userId"];
$userDetail["username"] = $result["db_username"];
$userDetail["userLoginName"] = $result["db_userLoginName"];
$userDetail["password"] = $result["db_password"];
$userDetail["usertype"] = $result["db_usertype"];
$userDetail["orgID"] = $result["OrgID"];
$userDetail["branchID"] = $result["BranchID"];
$userDetail["industryID"] = $result["IndustryID"];
$userDetail["db_phone"] = $result["db_phone"];
$userDetail["email"] = $result["db_email"];
$userDetail["address"] = $result["db_address"];
$userDetail["pincode"] = $result["db_pincode"];
$userDetail["city"] = $city;
$userDetail["state"] = $state;
// success
$response["success"] = 1;
// user node
$response["userDetail"] = array();
array_push($response["userDetail"], $userDetail);
// echoing JSON response
echo json_encode($response);
} else {
// no industry found
$response["success"] = 0;
$response["message"] = "No user found...";
// echo no users JSON
echo json_encode($response);
}
} else {
// no industry 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);
}
?>