Take the 2-minute tour ×

There is a contact form which current action is http://www.siteA.com/ContactInfo.php, it sends fields and values. In ContactInfo.php, i just catch the values and send and email to y@z.x

BUT, inside ContactInfo.php, I need to send the same data to another destination, in other domain http://www.SiteB.com/Reg.aspx

I have tryed out to create an http POST request to SiteB, but It doesn't work, even with another file in the same site.

I have not the code right now, but it's similar to this structure.

<? php

   // CREATE Http POST REquest to another www.siteB.com/Reg.aspx

I have tryed out using... HttpRequest object, cURL, and the other one...i can't remember the name.

share|improve this question
is the http://wwws. (note the s) a typo? –  Mark Elliot Feb 20 '10 at 5:08
add comment

3 Answers

You can try something like this using cURL (http://www.php.net/manual/en/curl.examples.php) ..

$sub_req_url = "http://www.siteB.com/Reg.aspx";

$ch = curl_init($sub_req_url);
$encoded = '';

// include GET as well as POST variables; your needs may vary.
foreach($_GET as $name => $value) {
  $encoded .= urlencode($name).'='.urlencode($value).'&';


// chop off last ampersand
$encoded = substr($encoded, 0, strlen($encoded)-1);

curl_setopt($ch, CURLOPT_POSTFIELDS,  $encoded);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);


share|improve this answer
add comment

I'd encourage you to try the Snoopy Class. It's really rather simple:


  $vars = array("fname"=>"Jonathan","lname"=>"Sampson");
  $snoopy = new Snoopy();

  $snoopy->httpmethod = "POST";
  $snoopy->submit("http://www.siteB.com/Reg.aspx", $vars);

  # Use the following if you need to view the results
  # print $snoopy->results;

share|improve this answer
add comment

Without seeing your code it's hard to say what the problem is.


Is site B a domain you also own, or is it third party? If it's third party they may be running bot checks and the like that would make your POST fail.

Have you done anything to confirm that the data is in fact being send to domain B?

If domain B is also under your control, my guess is they are running on the same web server - why not just write logic into the domain A page that does whatever it is that needs to be done without having to submit to domain B?

share|improve this answer
add comment

Your Answer


