Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Adding php variable to a form

Posted on 2013-02-06
5
309 Views
Last Modified: 2013-02-06
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
0
Comment
Question by:oconnork00
  • 3
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
yodercm earned 500 total points
ID: 38858905
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
 
LVL 2

Author Comment

by:oconnork00
ID: 38858938
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
 
LVL 27

Expert Comment

by:yodercm
ID: 38859045
Date?  What date?
0
 
LVL 2

Author Comment

by:oconnork00
ID: 38859105
Sorry, meant data.

Got it working now, thanks for the help yodercm
0
 
LVL 27

Expert Comment

by:yodercm
ID: 38859222
Oh, I see, ok, glad you got it working :)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question