Opening a new script with data passed via POST


I am trying to set up a script that will open another script while passing data to it via POST. I have seen various methods to achieve this, chiefly variatons on:

[php]function do_post_request($url, $data, $optional_headers = null)
$params = array(‘http’ => array(‘method’ => ‘POST’, ‘content’ => $data));
if ($optional_headers !== null){$params[‘http’][‘header’] = $optional_headers;}
$ctx = stream_context_create($params);
$fp = @fopen($url, ‘rb’, false, $ctx);
$response = @stream_get_contents($fp);
return $response;

[php]function do_post_request($url, $data)
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);

I think both are passing the POST data along to the other script, but they aren’t opening it. How do I get it to open with the POSTed data?

Sponsor our Newsletter | Privacy Policy | Terms of Service