title: Problems with storing longitude and latitude to databse
body: <p>I am trying to store the latitude and longitude coordinates to the database.</p>
  
  <p>The code below successfully write the username to database but is blank for longitude and latitude.</p>
  
  <p>Any ideas what I am doing wrong? </p>
  
  <p>Thanks </p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
  
  &lt;html&gt;
   &lt;head&gt;
    &lt;title&gt;Locate skills Reg&lt;/title&gt;
    &lt;style&gt;
  #header {
      background-color:black;
      color:white;
      text-align:center;
      padding:5px;
  }
  #side {
      line-height:30px;
      background-color:white;
      height:500px;
      width:250px;
      float:left;
      padding:5px;          
  }
  #main {
      width:350px;
      float:left;
      padding:10px;        
  }
  #aside {
      width:250px;
      float:right;
      padding:5px;
  }
  #footer {
      background-color:black;
      color:white;
      clear:both;
      text-align:center;
     padding:5px;      
  }
  &lt;/style&gt;
   &lt;/head&gt;
   &lt;body&gt;
  
   &lt;div id="header"&gt;
    &lt;h1&gt;Location/Skill Register&lt;/h1&gt;
    &lt;?php
                      session_start();
                      $username = $_SESSION['username'];
  
                      if($_SESSION['name'])
                      {
                          echo "Welcome, &lt;a href='userProfile.php'&gt;" .$_SESSION['login']."
                          &amp;nbsp&lt;/a&gt;&amp;nbsp | &lt;a href = 'logout.php'&gt;Log Out!&lt;/a&gt;";
                      }
                      else
                      {
  
                          echo '&lt;script type="text/javascript"&gt;'; 
                          echo 'alert("You must be logged in to do that!");'; 
                          echo 'window.location.href = "login.html";';
                          echo '&lt;/script&gt;';
                          //echo "&lt;a href = 'login.html'&gt;Login&lt;/a&gt; | &lt;a href = 'register.php'&gt;Register&lt;/a&gt;";
                      }
  
                      ?&gt;
  
   &lt;/div&gt;
  &lt;br&gt;
  &lt;div id="side"&gt;
  &lt;a href="homepage.php"&gt;
  &lt;img src="logo.png" alt="logo" style="width:200px;height:200px;border:0;"&gt;&lt;br&gt;
  Donate an Item Here&lt;br&gt;
  &lt;a href = "alldonations.php"&gt;List of donations&lt;br&gt;
  &lt;a href = "requestList.php"&gt;Request for Items&lt;/a&gt;&lt;br&gt;
  List of requested Items&lt;br&gt;
  My Account Posts&lt;br&gt;
  &lt;a href = "feedback.php"&gt;Feedback&lt;/a&gt;&lt;br&gt;
  &lt;br&gt;
  &lt;/div&gt;
  &lt;div id="main"&gt;
  
  &lt;table frame="border"  valign="center" align ="center"&gt;         
    &lt;form action ="locateskills.php" method ="POST" &gt;
  
          &lt;td&gt;&lt;input type="hidden" id = "latitude"  name="latitude"/&gt;&lt;/td&gt;                   
          &lt;td&gt;&lt;input type="hidden" id="longitude" name="longitude"/&gt;&lt;/td&gt;
          &lt;tr&gt;&lt;td&gt;Please enter description of skill your are providing or requesting for: &lt;/br&gt;
          &lt;textarea rows="4" cols="50" name = "description"&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;
         &lt;br /&gt;
         &lt;/td&gt;&lt;td align="right"&gt;&lt;input type= "submit" onclick="getLocation()" name = "submit" value="submit"&gt;&lt;/td&gt;&lt;/tr&gt;
                  &lt;/b&gt;&lt;/font&gt;
  
  &lt;/form&gt;
  &lt;/table&gt;
         &lt;br/&gt;
  
  &lt;Script&gt;
  
  function getLocation() 
  {
      if (navigator.geolocation)
      {
          navigator.geolocation.getCurrentPosition(showPosition);
      } 
      else 
      {
          alert("Geolocation Failed!");
      }
  }
  
  function showPosition(position) 
  {
        x.innerHTML = "Latitude: " + position.coords.latitude + 
      "&lt;br&gt;Longitude: " + position.coords.longitude;
  
    latitude = position.coords.latitude;
    longitude = position.coords.longitude;
    document.getElementById("latitude").value = String(latitude);
    document.getElementById("longitude").value = String(longitude);
  }
  &lt;/Script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;?php
  
  session_start();
  $submit = $_POST['submit'];
  $username = $_SESSION['login'];
  $latitude = $_POST['latitude'];
  $longitude = $_POST['longitude'];
  
  $connect = mysql_connect('HOST', 'USER', 'PASS') or die('Failed to connect!');
  mysql_select_db('DB') or die('Can\'t find Database!');
  
  if($submit)
  {                   
      mysql_query("INSERT INTO LOCATIONS VALUES ('$username', '$latitude', '$longitude')");
      echo '&lt;script type="text/javascript"&gt;'; 
      echo 'alert("Stored to Database");'; 
      echo 'window.location.href = "homepage.php";';
      echo '&lt;/script&gt;';
  }
  
  
  
  //close once finished to free up resources
    $db-&gt;close();
  
  ?&gt;
  </code></pre>