Jump to content

Question about "hidden" form fields


supergrover1981

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
Link to comment
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

Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.