SHARE
TWEET

Untitled

a guest Jun 15th, 2019 110 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <input type="text" name="flightnumber" id="flightnumber" onpointermove="showUser(this.value)" style="width: 70px;" maxlength="4">
  2.         <input type="text" name="dep" id="dep" style="width: 70px;">
  3.         <input type="text" name="arr" id="arr" style="width: 70px;">
  4.      
  5. <script>
  6.  
  7. function showUser(str) {
  8.   if (str.length=="") {
  9.     document.getElementById("dep").innerHTML="";
  10.     document.getElementById("arr").innerHTML="";
  11.  
  12.     return;
  13.   }
  14.   if (window.XMLHttpRequest) {
  15.     // code for IE7+, Firefox, Chrome, Opera, Safari
  16.     xmlhttp=new XMLHttpRequest();
  17.   } else { // code for IE6, IE5
  18.     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  19.   }
  20.   xmlhttp.onreadystatechange=function() {
  21.     if (this.readyState==4 && this.status==200) {
  22.         var myObj = JSON.parse(this.responseText);
  23.         document.getElementById("arr").innerHTML = myObj.dep;
  24.         document.getElementById("dep").innerHTML= myObj.arr;
  25.     }
  26.   }
  27.   xmlhttp.open("GET","getdata.php?q=" + str,true);
  28.   xmlhttp.send();
  29.  
  30.  
  31. </script>
  32.      
  33. <?php
  34. //look up the record based on email and get the firstname and lastname
  35.   $host_name = 'db5000091260.hosting-data.io';
  36.   $database = 'dbs85930';
  37.   $user_name = 'dbu68420';
  38.   $password = '';
  39.   $connect = mysqli_connect($host_name, $user_name, $password, $database);
  40.  
  41.     $q = $_GET['q'];
  42.     $myObj->dep = "";
  43.     $myObj->arr = "";
  44.  
  45.     $sql = "SELECT dep, arr FROM flights WHERE flightnumber = {$q}";
  46.     $result = mysqli_query($connect, $sql);
  47.  
  48.     if (mysqli_num_rows($result) > 0) {
  49.  
  50.     while($row = mysqli_fetch_assoc($result)) {
  51.  
  52.     $myObj->dep = $row['dep'];;
  53.     $myObj->arr = $row['arr'];
  54.  
  55.     $myJSON = json_encode($myObj);
  56.  
  57.     echo $myJSON;
  58.  
  59.     }
  60.     } else {
  61.     echo "0 results";
  62.     }
  63.  
  64.  
  65. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top