Page 1 of 1

Pass post data from a PHP script.

Posted: Mon Jan 15, 2007 11:28 am
by lex
Is there anyway to pass post data from PHP, with the header function, or with any other method.

Background:-

I've got a form which posts data to a PHP script. The script then validates the data. If there's an error it goes back to the form. If there's no error it does some db updates. I need it to then pass the relivent information to paypal. Paypal take this information in the form of hidden fields in a post form. But I don't want to build a page with the FORM and a 'click here to contiue' button, I want to do it all on the server side with PHP.

Any ideas.

Posted: Mon Jan 15, 2007 11:36 am
by feyd
Header() cannot do post data. cURL and other similar systems can however.

Posted: Mon Jan 15, 2007 12:55 pm
by Z3RO21
I had a similar issue while trying to interface with a login system of another site. What I ended up doing was using JavaScript to auto submit an invisible form loaded with all the information.

Posted: Mon Jan 15, 2007 1:37 pm
by Hyper
You need to send a POST request to PayPal with your data, thus emulating FORM behavior. There are facilities in cURL and PEAR to do this. If they aren't available to you then you'll have to write custom function for that. Don't worry, someone has already done that. Take a look here.

Posted: Mon Jan 15, 2007 6:27 pm
by volka
If you're using php 5 you might also be interested in example M-2 at http://de3.php.net/manual/en/wrappers.http.php

Posted: Wed Jan 17, 2007 10:56 am
by lex
Thanks for your help. I tried it with cURL, but I need the browser to actually go to paypal, rather than be serving the page as if it were on my site.

In the end I used javascript to auto submit the form. I wanted to avoid that, but I guess I need the form submitted by the client not the server and that seemed to be the only way to acheive it.