Source Code

Redirect URL with Send POST Data

  • anonymous
  • Jul 18' 14
  • PHP
  • 235
  • 148
  • United States

For some condition if you want to redirect to URL but send post data to redirected URL, in php can describe in simple function creation


'Mr','name'=>'Ano V','domain'=>'');
$data = http_build_query($data_array);

echo redirectPost('http://localhost/dom/baca.php', $data);
function redirectPost($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;


in redirect target baca.php file you can test it by print out the parameters


  • Tags : redirect, post, sending, data
comments powered by Disqus

Related Code

Mysql Response too slow accessed from website

Dumping MySQL Database Using Command

Source Code - PQM - Pingi Query Manager

Select a random datarecord

Create DB file at runtime

Get Database Path With Alias

SQL data to Excel

Save a StringGrid as a CSV file

Get database path with its alias