supergrover1981 Posted October 17, 2006 Share Posted October 17, 2006 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']); ?>...<?phpif ($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 Quote Link to comment Share on other sites More sharing options...
akitchin Posted October 17, 2006 Share Posted October 17, 2006 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? Quote Link to comment Share on other sites More sharing options...
supergrover1981 Posted October 17, 2006 Author Share Posted October 17, 2006 *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 it2.) If the variable satisfies a condition, send that variable to paypalI 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 Quote Link to comment Share on other sites More sharing options...
akitchin Posted October 18, 2006 Share Posted October 18, 2006 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.