Opening a new script with data passed via POST

Hi,

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]

or:
[php]function do_post_request($url, $data)
{
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
curl_exec($handle);
}[/php]

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