PHP - Send Post information


First, my topic is not about how to get $_POST data.

My problem is sending $_POST data, without using an form (or any html at all), and I don’t want to use $_GET.

I read various articles about how to let PHP send $_POST data, but until now, none of them work.
Either I get a “Service Temporarily Unavailable” error, or nothing happens and it shows a blank page.

My code until now (from ), showing a blank page:
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);
if (!$fp) {
throw new Exception(“Problem with $url, $php_errormsg”);
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception(“Problem reading data from $url, $php_errormsg”);
return $response;
$url = ‘’;
$data = array(‘http’ => array(
‘error’ => ‘403’
do_post_request($url, $data, $optional_headers)


So I want it to redirect to ‘’, sending the $_POST data “error = 403”. (This should no be visible in the URL, so no $_GET)

Thanks in advance,


Its going to show in the address box unless you’re using mod rewrite - no way around it that I know of. you’re missing a ; at the of the function call.

You can send post data using cURL

Sponsor our Newsletter | Privacy Policy | Terms of Service