Forum Moderators: coopster
Basically I'm submitting from form1.php to [remote.server.com...] using POST. This works fine on it's own, but I want to introduce a PHP script in the middle to do some data manipulation before proceeding onwards.
After successfully setting up $postdata, I'm using this to try and send it...
sendPOST($postdata,"/anotherscript.asp"); function sendPOST($PostData, $Uri) { $ContentLength = strlen($PostData);
$Host = "remote.server.com";
$Script = $Host . $Uri;
header("location: $Script");
$ReqHeader =
"POST $Uri HTTP/1.0\n".
"Host: $Host" . ":443\n".
"Content-Type: application/x-www-form-urlencoded\n".
"Content-Length: $ContentLength\n\n".
"$PostData";
// Open the connection to the host
$socket = fsockopen($Host, "443");
if($socket) {
fputs($socket, $ReqHeader);
//while (!feof($socket)) {
// $result .= fgets($socket,1024);
//}
}
fclose($socket);
if($result) echo $result;
}
[edited by: Igau at 4:40 pm (utc) on July 13, 2004]
$URL = $Host . $Uri;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://$URL");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $PostData);
curl_exec ($ch);
curl_close ($ch);
header("location: myserver/script.asp); If I miss out the header("location") part, it doesn't redirect to the page I'm submitting data to... I must be doing something fundamentally wrong somewhere here.