Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var link = 'http://www.testhostfile.com/GetData.php';
- $http({
- url: link,
- method: "GET",
- headers: {'Content-Type': 'application/x-www-form-urlencoded'},
- data: $scope.inmateData.IMID
- }).then(function (res){
- alert('Success');
- console.log(res);
- });
- <?php
- $db_name = 'testDb';
- $hostname = 'localhost';
- $username = 'testName';
- $password = 'password';
- $usertable = "InMateMaster";
- $fileData = file_get_contents("php://input");
- $request = json_decode($fileData);
- if (isset($request)) {
- $imID = $request->IMID;
- echo($imID);
- }
- $db = new mysqli("localhost",$username,$password,$db_name);
- if($db->connect_errno > 0) {
- die('Unable to connect to database[' .$db->connect_error. ']');
- }
- $sql = "SELECT * FROM InMateMaster WHERE IMID = 'KAS9791257393'";
- if(!$result = $db->query($sql)){
- die('There was an error running the query [' .$db->error. ']');
- }
- $arr = array();
- if($result->num_rows > 0) {
- while($row = $result->fetch_assoc()) {
- $item = array();
- $item['IMName'] = $row['IMName'];
- $item['IMMobile'] = $row['IMMobile'];
- $item['IMFatherName'] = $row['IMFatherName'];
- $arr[] = $item;
- }
- }
- header('Content-Type: application/json');
- echo json_encode($arr);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement