0

// Edit //

Essentially the question is how best to send a (potentially large) block of dynamically generated HTML to a remote server after processing a form?

// End Edit

Client has a sign up form that is included across many domains which posts back to mother site. We have been, up until now, using the mother site's Thank You page for all requests.

Client would like to now allow affiliates to populate a form field with $thankyou_url and have use redirect to the affiliate site's designated thanks page.

As there are an ever-changing variety of responses we give to these sign-ups we want to build some HTML and post it to the supplied thanks page for display.

I had thought I would build the post in cURL but I am finding what I do there is fetch back their populated response page with its relative paths.

Is there a way to use a different cURL header to send user with post we built or is there some other method I should use?

Current code:

<?php
$url = $remote_thanks_url;
$fields = array(
            'html' => $our_response
        );
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
$result = curl_exec($ch);
curl_close($ch);
?>
jerrygarciuh
  • 21,158
  • 26
  • 82
  • 139

1 Answers1

0

You might want to have a look at the header() function (http://www.php.net/header) like in this example:

How do you POST to a page using the PHP header() function?

Community
  • 1
  • 1
Tom
  • 3,031
  • 1
  • 25
  • 33
  • The answers to that post suggest that the header() function is not a correct way to do this. – jerrygarciuh Jan 19 '13 at 18:38
  • The other post is trying to do the opposite of you. He wants to make a call to another page without sending the customer there. I assume you do want to send them there (i.e.: your solution fits his problem. His fits yours). – Tom Jan 19 '13 at 19:32
  • Thanks Tom, when implemented the headers in the other post prompt the download of a zero byte file with the name of the receiving php script. I decided simple would do and implemented an auto-posting form on the results page that sends my post onload. – jerrygarciuh Jan 22 '13 at 20:07