Hello everyone,

I am using the following code to do a post to localhost:

$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost/response.php');
//response.php just spits out json_encode($_POST)
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/html"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, Array('data' => $xml));
$curl_result = curl_exec($ch);
if(curl_errno($ch)) {
	echo 'Curl error: '.curl_error($ch);
}
curl_close($ch);
echo $curl_result;
//Outputs []

As stated in the comment, nothing gets posted to the server. What am i doing wrong?:confused:
BTW: If i change Array('data'=>$xml) to simply $xml (which is a string constructed previously) it stops working altogether (just as if a syntax error occurred).
Thanks !

Do you receive any error like this?

"Fatal error: Call to undefined function curl_init() in ....../xxxx.php

No, Curl is installed.
No error whatsoever.
I just get a blank $_POST.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.