I have two files active.php and passive.php. I want active.php to post data without user interaction to passive.php, as explained here. If my code worked, in the end the $_POST array should contain 'Name'=>'John Doe' instead of being empty as my navigator informs me. What did I do wrong ?
I am fully aware that there are solutions using either Javascript (as explained here ) or cURL (as explained here ), but this question is specifically about the PHP-only method, so please do not post any comment or answer involving Javascript or cURL.
Contents of passive.php :
<?php
var_dump($_POST);
?>
Contents of active.php :
<?php
$post_data=array('Name'=>'John Doe');
$url='http://localhost:8888/passive.php';
$params = array('http' => array(
'method' => 'POST',
'content' => $post_data
));
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
$response = @stream_get_contents($fp);
fclose($fp);
var_dump($response);
?>