# [web] Forward POST info, or submit to 2 pages at the same time?

## Recommended Posts

I'm taking some user info that we need to process and another company also needs to process. When we're done, they should be on the other company's website. Right now I'm doing this:
function SubmitForm() {
document.getElementById('plandocform').action = "ourscript.php";
document.getElementById('plandocform').submit();

document.getElementById('plandocform').action = "http://www.them.com/theirscript.php";
document.getElementById('plandocform').submit();
}

Unfortunately, this seems not to work sometimes (non-reproducible, about 1/4 of the time). That is, it will submit only to the second form (the other company's form). So is there some way to have the form submit to our page, then forward all the POST info on as POST info to them.com using PHP?

##### Share on other sites
Lookup curl (http://www.php.net/curl), it should be able to do what you are looking for, beware though, hosts might not have it enabled!

http://pecl.php.net/package/pecl_http - This is also very interesting, but it's not very well documented. See here for a list of functions in that extension.

##### Share on other sites
cURL's not quite it, I think. Let me clarify--the end result that we want is for the user's web browser to end up looking at www.them.com/theirscript.php as if they had posted directly to it. The post to ourscript.php is just to save a record of their request for audit-trail purposes. So the javascript I posted really does exactly what we want... but only when it works [smile]

I think the closest I could get with cURL is to POST to them.com myself and act as proxy to send the resulting page back to the user, but that's unfortunately not good enough.

##### Share on other sites
Instead of submitting the form twice, you might be able to POST to the first script using XMLHttpRequest.

##### Share on other sites
You could also try something hokey by creating another page. Process the first request on page one, process the second on page two. One redirects to two, two goes where you would normally have it go.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

• ### Forum Statistics

• Total Topics
627737
• Total Posts
2978873

• 10
• 10
• 21
• 14
• 12