posting PHP to ASP

Emagine

Perch
Staff member
Hi all,

i have a page in php that needs to do a http post (in the code)

to a .asp page.

or i can send it using a XML envelope.

ive not got much luck posting to the page.

wondering if anyone can see whats up

it has to be from php to asp , i cant change it :D

here is the xml; i was tring


<?

$url = "http://www.domain.com/insert.asp";
$data = "<score>" . $_POST['value'] . "</score>";
$req = new HTTP_Request($url);
$req->addHeader("Content-Type", "text/xml");
$req->addHeader("Content-Length", strlen($data));
$req->setMethod("POST");
$req->addRawPostData($data, true);
$req->sendRequest();

echo $req->getResponseBody();
?>


it says there is an issue with line 5 first line of req

any points appriceated
 
That's not PHP 8o

Try using this handy function:

$data = "var1=abc&var2=def"
$host = "www.domain.com";
$path = "/insert.asp";

function PostToHost($host, $path, $data) {

$fp = fsockopen($host,80);

fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: text/xml\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data);

fclose($fp);
}
 
Back
Top