I also want to post data (XML, but that shouldn't matter) with a redirect.
I currently found that with PEAR you can make a request and get the response:
require_once('HTTP/Request.php');
$req =& new HTTP_Request($url);
$req->addHeader("Content-Type", "text/xml");
$req->addHeader("Content-Length", strlen($xml));
$req->setMethod(HTTP_REQUEST_METHOD_POST);
$req->addRawPostData($xml, true);
$req->sendRequest();
echo $req->getResponseBody();
This will make the response body show in you browser. So i'm almost there. But i want the user to really go to that url, instead the page calling it and just display the body. Because like this, i only get the HTML, but the CSS and other included files are missing. Also it has some relative urls, so if i click one, it fails, because i'm still at the original domain. (the url points to another domain).
so i want i sort of header('Location:'.$url), but then with POST data included.
EDIT
I solved this as follows:
$xml = “<xml>...”
$postHtml = "<html>";
$postHtml .= "<body>";
$postHtml .= "<form id='myform' name='myform' method='POST'
action='".$domain."/Purchase.aspx?a=123'>";
$postHtml .= "<input type='hidden' id='OrderXml' name='OrderXml'
value='".$xml."' />";
$postHtml .= "</form>";
$postHtml .= "<script
lang='Javascript'>document.myform.submit();</script>";
$postHtml .= "</body>";
$postHtml .= "</html>";
echo $postHtml;