|  | Posted by Jean-Jacques SOLARI on 06/19/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] |