Pregunta

I'm trying to use a custom form, to populate over fields in another form, which is hosted on jotform.

With rails, moving over info is pretty easy, but I'm not sure how to do it in php.

I have a custom form set up which has the fields for the number of guests, the check in date, and the check out date.

What I'd like to do is to make it so that when I hit submit on the first form, it would populate the data on the reservation form.

The reservation is hosted on jotform.

I tried testing this by matching the ID of the fields ( i.e the same as on jotform), but when I click submit, it doesn't transfer over the data.

--

You can replicate this by going to http://opohills.com/taipei-rentals.php and entering information right under the slider

--

What what I write in PHP which would carry the information over?

Is this on my end, or on jotform's?

The code for my custom form is --

    <form id="formElem" name="formElem" action="form.php" method="post" >

     <div class="icon">

      <select id="input_13" name="capacity" >

        <option value="1">1</option>

        <option value="2">2</option>

        <option value="3">3</option>

        <option value="4">4</option>

        <option value="5">5</option>

        <option value="more">6+</option>

      </select>

      <span><img src="img/man.png" /></span>

     </div>

     <div class="icon">

      <input id="txtFromDate" name="check_in" placeholder="mm/dd/yy" type="text" readonly="readonly" AUTOCOMPLETE=OFF />

      <span><img src="img/calendar.png" /></span>

     </div>

     <div class="icon">

      <input id="txtToDate" name="check_out"   placeholder="mm/dd/yy"  type="text" readonly="readonly" AUTOCOMPLETE=OFF />

      <span><img src="img/calendar.png" /></span>

     </div>

     <button id="btn_room_search" type="submit" class="secondary button submit_button">Inquire Now</button>



    </form>
¿Fue útil?

Solución

If you're saying you want your PHP form to submit this data to a remote host automatically then what you need is to generate another HTTP request to the remote host (basically proxying the data over to the remote host).

However, if what you're saying is that you want the form data populated on your page to be populated automatically on some other remote host's page then there's simply nothing PHP can do to help you with that. You will need access to the remote host and you'd have to make modifications to that code to accept remote requests that will automatically populate the page's form elements.

The proxy request can be as simple as this...

$postdata = http_build_query($_POST); /* do your own validation here */

$opts = array(
              'http' => array(
                             'method'  => "POST",
                             'header'  => "Accept-language: en\r\n" .
                                          "Cookie: foo=bar\r\n", /* if necessary */
                             'content' => $postdata
                            ),
             );

$context = stream_context_create($opts);

$file = file_get_contents('http://www.example.com/', false, $context);

And that basically just proxies what was sent to your PHP script to the remote host. See PHP HTTP Stream Context Options for more details.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top