I'm new to php and i want to send some data to a url and write the respond from server. Whatever i try the response is empty Here is the code
$post_data['userid'] = "demo";
$post_data['password'] = "demo";
$post_data['to'] = "$to";
$post_data['message'] = iconv("UTF-8","Windows-1253","$text");
$post_data['from'] = 'sender';
//traverse array and prepare data for posting (key1=value1)
foreach ( $post_data as $key => $value) {
$post_items[] = $key . '=' . $value;
}
//create the final string to be posted using implode()
$post_string = implode ('&', $post_items);
//create cURL connection
$curl_connection = curl_init('http://www.lexiconsoftware.gr/sms/warrior.asp');
//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curld, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curld, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($curld, CURLOPT_COOKIEFILE, 'cookie.txt');
//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
//perform our request
$result = curl_exec($curl_connection);
//show information regarding the request
//print_r(curl_getinfo($curl_connection));
//echo curl_errno($curl_connection) . '-' . curl_error($curl_connection);
$getresult = curl_get_contents($result);
echo $getresult;
$http_data = curl_exec($curld);
$curl_info = curl_getinfo($curld);
$headers = substr($http_data, 0, $curl_info['header_size']); //split out header
echo "Message Status: $http_data, headers: $headers<br><a href=\"smser.php\">Send New</a>";
//close the connection
curl_close($curl_connection);
The code sends the data but there is no response, just an empty page