How to post vars to an external gateway?

Posted by cnapsys, 09-21-2008, 10:05 PM
Hi guys, I need to send some variables to an external gateway. I am not using a Form with a submit button. I have all the vars from a db so there's no need to force the user to enter them again. However when I try to use some unexpected results come up. What I have tried so far was to generate a
with hidden fields that have the values entered from a query and then use to send the data to the other server automatically. Any help is greatly appreciated, ty

Posted by Tim Greer, 09-21-2008, 11:11 PM
onload will not work with values in hidden fields in a form. You need to put them in the query string I'd recommend a different way of doing that, but it depends on how your site is working. Does it matter a lot on how it should be working, or does it matter as long as it submits to the other site?

Posted by cnapsys, 09-21-2008, 11:32 PM
hey Tim, thanks for your quick reply. onload does seem to work fine. after several tests I was able to send the data with no problems. However the downside is that, even though the page is expired if you try to hit the back button or stop it before it does the redirection, you can actually view the source and see all the hidden field values. Most of em are encrypted but still I would rather use a different approach. I've done some reading and googled some options. I do not have cURL and would not be comfortable using it. What other options are there???? c

Posted by Tim Greer, 09-21-2008, 11:36 PM
You can use curl, fopen, sockets, and various other solutions. You can then create a redirect so once the fields are all verified as existing, it can redirect them to the other site with those fields in the URL. If you don't want them to be able to see the fields, then you can do a few things; One would be to have the script submit the fields and then redirect them, but it can depend if they (their browser) needs to create a session or something, or if you can predetermine a session. So, a safer method would be to have your script itself submit the data (post method) to the other site and then actually grab the output and present that output to the user on your site, from the submission results to the remote site. This is the best and safest method, especially when interfacing with a gateway. It allows you for great control and you can create your own API, even. It can really be as simple as just a few lines to work exactly how you want and interface with the gateway (and I'm not exaggerating).

Posted by cnapsys, 09-22-2008, 09:29 AM
hi Tim, thanks again for your time. I do not have curl installed on my server. So after checking the data and making sure everything is ok how would I go about posting it to the gateway with pure php? The thing is that the gateway needs user interaction after I submit the data. I can not grab a response code right after I submit it. The user needs to fill in a checkout form with cc# and billing info on the gateway. After they press submit on that form I can have them redirect the user back to a confirmation page on my server. So my main question is... how do i make the post? c

Posted by webcertain, 09-22-2008, 09:44 AM
with curl :p otherwise, open a php socket and write a class to send HTTP headers over :p

Posted by Tim Greer, 09-22-2008, 04:52 PM
Well, there are several ways of doing this. For things like this, I personally connect over SSL via POST with Net::SSLeay, but you can do similar things in PHP, such as using sockets, over SSL and post their data to the remote site, and outputting the response page so they can continue from there, but I'd personally have it post and output, but do everything on my end, again, posting to the remote site when needed over SSL (keeping them on an SSL area of my own site). I apologize if that's a little vague, but I'm trying to avoid suggesting something more than you want to do, just because of how I'd do it. See http://us2.php.net/function.fsockopen and some examples there. Here's a site that's relevant for both fsockopen and curl examples: http://www.alt-php-faq.org/local/55/ Again, this isn't the exact way I'd do it, but it should work fine, and you can code it specifically. In other words, whatever method you use, you shouldn't need to have the user's see the variables/fields in the page source.

Kas see vastus oli kasulik?

 Prindi artikkel

Loe veel

Mysql query LIKE%

Posted by net4all, 03-12-2010, 05:32 AMI got a special mysql-problem: I have a table containing...

Need to Delete a Cronjob via SSH

Posted by epic1231, 03-23-2007, 11:12 AMI have a cronjob that is still entered in my server, but...

iFrame keeps opening a new windows onlick

Posted by bambinou, 11-06-2012, 11:29 AMHello, I am totally lost with this one. I have an...

3-line PHP chat

Posted by Looie, 01-15-2008, 03:28 PMJust an idea I had http://www.ehwtf.com/stuffz/chat...

aletia reseller

Posted by hostchecker, 09-27-2001, 05:36 PMwhas the URL for aletia reseller plans? Posted by...