title: Get geolocation by Javascript and save it to text file via php
body: <p>I want to get latitude and longitude of the guest and save them to a text file..</p>
  
  <p>I used this:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  
  &lt;?php
  
   $location = print '
     &lt;SCRIPT LANGUAGE="JavaScript"&gt;
  window.onload=function(){
  if(navigator.geolocation)
  {
  navigator.geolocation.getCurrentPosition(showPosition);
  }
  else
  {
  alert("Geolocation is not supported by this browser.");
  }
  }
  function showPosition(pos){
  document.write("Location: "+pos.coords.latitude+","+pos.coords.longitude);
  &lt;/script&gt;
  '
  
  ;
  
  
  
  $Seb = "*******************" ;
   $file = "save.txt";
   $a = fopen($file, "a");
   fwrite($a,$location."\r\n");
      fwrite($a,$Seb."\r\n");
   fclose($a);
  
  
  ?&gt;
  &lt;form action="index.php"&gt;
  &lt;input type="submit" value="Refresh"&gt;
  &lt;/form&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>but the result in the text file is :</p>
  
  <pre><code>1
  </code></pre>
  
  <hr>
  
  <p>with out any geolocation data</p>
  
  <p>Any Help please?</p>