title: Get geolocation by Javascript save to txt (Java/PHP)
body: <p>Just trying to save the geolocation and IP address to a php file  I saws this code, but it doesnt save any info to the pho file</p>
  <p>Index.html</p>
  <pre><code>&lt;script&gt;
  window.onload=function(){
      if(navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(showPosition);
      }else{
          alert(&quot;Geolocation is not supported by this browser.&quot;);
      }
  }
  function showPosition(pos){
      $.post('saver.php',{'lat':pos.coords.latitude,'lng':pos.coords.longitude},function(res){
        console.log(res);
     });
  }
  &lt;/script&gt;
  </code></pre>
  <p>saver.php</p>
  <pre><code>&lt;html&gt;
  &lt;script&gt;
  &lt;?php
     print_r($_POST);
     $a = fopen(&quot;save.txt&quot;, &quot;a&quot;);
     fwrite($a,&quot;Location: $_POST[lat],$_POST[lng]&quot;);
     fclose($a);
  ?&gt;
  &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>
  <p>After running the html and clicking allow to get my location.  It saves to save.txt, but the result is only.</p>
  <pre><code>Location: ,Location: ,
  </code></pre>
  <p>Any idea on what to edit to research.  Also would like it to save the IP address as well.</p>
  <p>Thank you
  -Noob</p>