Advertisement
Guest User

Untitled

a guest
Sep 9th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. var link = 'http://www.testhostfile.com/GetData.php';
  2.  
  3. $http({
  4. url: link,
  5. method: "GET",
  6. headers: {'Content-Type': 'application/x-www-form-urlencoded'},
  7. data: $scope.inmateData.IMID
  8.  
  9. }).then(function (res){
  10. alert('Success');
  11. console.log(res);
  12. });
  13.  
  14. <?php
  15.  
  16. $db_name = 'testDb';
  17. $hostname = 'localhost';
  18. $username = 'testName';
  19. $password = 'password';
  20. $usertable = "InMateMaster";
  21.  
  22. $fileData = file_get_contents("php://input");
  23. $request = json_decode($fileData);
  24.  
  25. if (isset($request)) {
  26.  
  27. $imID = $request->IMID;
  28.  
  29. echo($imID);
  30. }
  31.  
  32. $db = new mysqli("localhost",$username,$password,$db_name);
  33.  
  34. if($db->connect_errno > 0) {
  35. die('Unable to connect to database[' .$db->connect_error. ']');
  36. }
  37.  
  38. $sql = "SELECT * FROM InMateMaster WHERE IMID = 'KAS9791257393'";
  39.  
  40.  
  41. if(!$result = $db->query($sql)){
  42. die('There was an error running the query [' .$db->error. ']');
  43. }
  44.  
  45. $arr = array();
  46. if($result->num_rows > 0) {
  47. while($row = $result->fetch_assoc()) {
  48. $item = array();
  49. $item['IMName'] = $row['IMName'];
  50. $item['IMMobile'] = $row['IMMobile'];
  51. $item['IMFatherName'] = $row['IMFatherName'];
  52. $arr[] = $item;
  53. }
  54. }
  55.  
  56. header('Content-Type: application/json');
  57. echo json_encode($arr);
  58.  
  59. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement