Adding php variable to a form

Hi all,

I am working on a project that will allow a user to press a button and thier latitude and longitude details are submitted through a form.

I have the lat and long module covered, which I got from www.locationdetection.mobi and I've attached the three files it uses.

Now, here's the problem.

I cannot figure out how to integrate my fotform to grab the latitude and longitude details from the forms.

Here is the form I wish to submit and which will be hopefully embedded into the geo.html page:

<script src="http://jotformpro.com/min/g=jotform?3.1.1502" type="text/javascript"></script>
<script type="text/javascript">
   JotForm.init();
</script>
<link href="http://jotformpro.com/min/g=formCss?3.1.1502" rel="stylesheet" type="text/css" />
<link type="text/css" rel="stylesheet" href="http://jotformpro.com/css/styles/nova.css?3.1.1502" />
<style type="text/css">
    .form-label{
        width:150px !important;
    }
    .form-label-left{
        width:150px !important;
    }
    .form-line{
        padding-top:12px;
        padding-bottom:12px;
    }
    .form-label-right{
        width:150px !important;
    }
    .form-all{
        width:690px;
        color:#555 !important;
        font-family:'Lucida Grande';
        font-size:14px;
    }
    .form-radio-item label, .form-checkbox-item label, .form-grading-label, .form-header{
        color:#555;
    }

</style>

<form class="jotform-form" action="http://submit.jotformpro.com/submit/30362045658958/" method="post" name="form_30362045658958" id="30362045658958" accept-charset="utf-8">
  <input type="hidden" name="formID" value="30362045658958" />
  <div class="form-all">
    <ul class="form-section">
      <li class="form-line" id="id_2">
        <div id="cid_2" class="form-input-wide">
          <div style="margin-left:156px" class="form-buttons-wrapper">
            <button id="input_2" type="submit" class="form-submit-button">
              Submit
            </button>
          </div>
        </div>
      </li>
      <li style="display:none">
        Should be Empty:
        <input type="text" name="website" value="" />
      </li>
    </ul>
  </div>
  <input type="hidden" id="simple_spc" name="simple_spc" value="30362045658958" />
  <script type="text/javascript">
  document.getElementById("si" + "mple" + "_spc").value = "30362045658958-30362045658958";
  </script>
  <input type="hidden" class="form-hidden" value="" id="input_4" name="q4_latitude4" />
  <input type="hidden" class="form-hidden" value="" id="input_5" name="q5_longitude" />
</form>

Open in new window




How will I chop and change this around in order to accomplish what I need? If you'd like to see the working demo I have up, please visit here. Please note it will ask you to share your location. I am not tracking/recording any locations on this page - I'm simply using the supplied three files below.

Thanks in advance for your help with this.
geo.html
geo.js
geo.php
LVL 2
oconnork00Asked:
Who is Participating?
 
Cornelia YoderConnect With a Mentor ArtistCommented:
First get the lat and long values into a php variable such as $lat and $long.

Then (in html) put them into the form using this

<input type=hidden name=lat value=<?php  echo $lat; ?>'>
<input type=hidden name=long value=<?php  echo $long; ?>'>

In the action script, you retrieve hidden inputs the same as any other, for example in Post,

$lat = $_POST["lat"];
0
 
oconnork00Author Commented:
Thanks yodercm,

Here's the new page

Unfortunately it's not bringing in the date I need. Here's the code I edited (your part suggested is at the bottom):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=windows-1250">
  <meta name="generator" content="Andy Moore: http://locationdetection.mobi/">
  <title>Location Detection Example</title>
  </head>
  <body>
	  <h1>Accept Browser Location Detection</h1>
		<div id="geo" class="geolocation_data"></div>
		<script type="text/JavaScript" src="geo.js"></script>
  </body>
</html>
<script src="http://jotformpro.com/min/g=jotform?3.1.1502" type="text/javascript"></script>
<script type="text/javascript">
   JotForm.init();
</script>
<link href="http://jotformpro.com/min/g=formCss?3.1.1502" rel="stylesheet" type="text/css" />
<link type="text/css" rel="stylesheet" href="http://jotformpro.com/css/styles/nova.css?3.1.1502" />
<style type="text/css">
    .form-label{
        width:150px !important;
    }
    .form-label-left{
        width:150px !important;
    }
    .form-line{
        padding-top:12px;
        padding-bottom:12px;
    }
    .form-label-right{
        width:150px !important;
    }
    .form-all{
        width:690px;
        color:#555 !important;
        font-family:'Lucida Grande';
        font-size:14px;
    }
    .form-radio-item label, .form-checkbox-item label, .form-grading-label, .form-header{
        color:#555;
    }

</style>

<form class="jotform-form" action="http://submit.jotformpro.com/submit/30362045658958/" method="post" name="form_30362045658958" id="30362045658958" accept-charset="utf-8">
  <input type="hidden" name="formID" value="30362045658958" />
  <div class="form-all">
    <ul class="form-section">
      <li class="form-line" id="id_2">
        <div id="cid_2" class="form-input-wide">
          <div style="margin-left:156px" class="form-buttons-wrapper">
            <button id="input_2" type="submit" class="form-submit-button">
              Submit
            </button>
          </div>
        </div>
      </li>
      <li style="display:none">
        Should be Empty:
        <input type="text" name="website" value="" />
      </li>
    </ul>
  </div>
  <input type="hidden" id="simple_spc" name="simple_spc" value="30362045658958" />
  <script type="text/javascript">
  document.getElementById("si" + "mple" + "_spc").value = "30362045658958-30362045658958";
  </script>
<input type=hidden name=lat value=<?php  echo $lat; ?>'>
<input type=hidden name=long value=<?php  echo $long; ?>'>

</form>

Open in new window


Do I need to wait for it to load? Is it even in the right place?
0
 
Cornelia YoderArtistCommented:
Date?  What date?
0
 
oconnork00Author Commented:
Sorry, meant data.

Got it working now, thanks for the help yodercm
0
 
Cornelia YoderArtistCommented:
Oh, I see, ok, glad you got it working :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.