You are here: Re: how to get values of a redirected a POST request ? « PHP Programming Language « IT news, forums, messages
Re: how to get values of a redirected a POST request ?

Posted by Jean-Jacques SOLARI on 10/14/92 11:50

Richard Levasseur <richardlev@gmail.com> wrote:

> You lose posted data when you redirect. You would need to re-post the
> data along with sending the redirect, which i'm not sure is possible,
> never tried it myself.

Yes, it's possible :)

Using Curl, you might try something like this (adjust to fit your
needs):

if( condition )
{
$rePosts = '';

foreach( $_POST as $pk => $pv )
{
$rePosts .= "&$pk=" . urlencode($pv);
}

$rsrc = curl_init( 'http://site_to_redirect_to/remote_script.php' );

if( is_resource($rsrc) )
{
curl_setopt( $rsrc, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt( $rsrc, CURLOPT_POST, 1 );
curl_setopt( $rsrc, CURLOPT_POSTFIELDS, ltrim($rePosts, '&') );
curl_setopt( $rsrc, CURLOPT_HEADER, 0 );
curl_setopt( $rsrc, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt( $rsrc, CURLOPT_RETURNTRANSFER, 1 );

curl_exec( $rsrc );
curl_close( $rsrc );

exit;
}
else
{
// some error handling...
}
}

hih,

JJS.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация