Jump to content

Archived

This topic is now archived and is closed to further replies.

supergrover1981

Question about "hidden" form fields

Recommended Posts

Gidday guys,

I'm trying to write a php script that takes the values from text input fields, and if the values are over a certain quantity, posts them as hidden variables to a 3rd-party site. Sample of the current code looks like this:

[code]
<?php
        $prodlistcount = 0;
$hicarbqty = htmlentities($_POST['hicarbqty']);  
$hiefiqty = htmlentities($_POST['hiefiqty']);
?>

...

<?php

if ($hicarbqty > 0) {
$prodlistcount++;
echo "<input type='hidden' name='item_name_$prodlistcount' value='Hiclone Fuel Efficiency Device'>
;}

if ($hiefiqty > 0) {
$prodlistcount++;
echo "<input type='hidden' name='item_name_$prodlistcount' value='HiClone (For EFI)'>
;}
?>

[/code]

What I would like to do is take input values *from the same page* as this PHP, instead of posting it from the prior page. Does anyone know if/how this can be done? Any help would be very appreciated.

Lotsa thanks gang,
                        - JB

Share this post


Link to post
Share on other sites
your question isn't totally clear.  are you asking if there's anyway to send these hidden input values to the third party script (i assume paypal or something similar) directly from the form that their quantities are input on?

Share this post


Link to post
Share on other sites
*grin* Hi Akitchin - thanks for the quick response. :-)

Yes, you're right - I'd like to send input values to paypal directly from the form that their quantities are input on.


The difficult part is that I only want to send input values that satisfy a conditional, so instead of just outputting the form to paypal, I need to:

1.) Take the variable entered into the form and evaluate it
2.) If the variable satisfies a condition, send that variable to paypal

I can do this over 2 forms via the "post" command, but ideally I'd like to do it from just the single form. Any help most appreciated. :-)

Cheers,
        - JB

Share this post


Link to post
Share on other sites
unfortunately i'm not sure there's a reliable way of doing this.  to intercept the POST variables BEFORE the form is sent requires javascript; the problem there is that javascript cannot be relied upon to do requisite work for a variety of reasons (the primary being that it is client-side, and thus can be disabled, fudged with, etc.)

you COULD take the POST variables once the form is sent, add the required variables to the POST array directly, and construct a manual POST request to the paypal target.  this won't emulate the typical form POST though, in that it's hard to construct a manual POST request while also forwarding the user to the target.

i guess what i'm trying to say is that coming from experience (i've tried dealing with this exact scenario before) it's probably a lot less leg(finger?)work to just issue a "confirmation" page which creates the hidden inputs, as you're currently doing.  perhaps someone else can shed more light, though.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.