Pass post data from a PHP script.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lex
Forum Newbie
Posts: 4
Joined: Tue Jul 11, 2006 11:00 am

Pass post data from a PHP script.

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Header() cannot do post data. cURL and other similar systems can however.
Z3RO21
Forum Contributor
Posts: 130
Joined: Thu Aug 17, 2006 8:59 am

Post 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.
Hyper
Forum Newbie
Posts: 2
Joined: Mon Jan 15, 2007 12:10 pm

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
lex
Forum Newbie
Posts: 4
Joined: Tue Jul 11, 2006 11:00 am

Post 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.
Post Reply