What I need to do, is to make a script, which submit a $_POST query to remote host, and that host is returning an answer on $_POST:
<?php
if($_POST['passkey'] == "c")
echo "OK";
else
echo "FAILED";
?>
I use this code:
function get_client_answer( $source_host='http://www.example.com/',$source_file='validate.php') {
$postdata = http_build_query(
array(
'message' => 'a',
'amount' => 'b',
'passkey' => 'c'
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata,
'max_redirects' => 0,
'ignore_errors' => true,
'timeout' => 10 // seconds
)
);
$context = stream_context_create($opts);
// Open the file using the HTTP headers set above
$file_content = @file_get_contents($source_host.$source_file, false, $context);
return $file_content;
}
But If I do:
<?php
echo get_client_answer("http://www.mywesite.com/", "validate.php");
?>
It returns me a blank text.
The problem is - how to get a response, that my last code will return "OK" or "FAILED"