1

usually when i want to redirect from one php page to another php page of same project i'm using

header("location:somepage.php");

This will cause more calls between client and server. What i want to do is instead of sending redirect header, i want to stop execution of requested page and pass request object or request information to the another page which i want to redirect. In this case single request will be enough. I guess this kind of functionality available in jsp. Is same thing available in php which i don't know?

Sam
  • 7,252
  • 16
  • 46
  • 65
Ravi MCA
  • 2,491
  • 4
  • 20
  • 30
  • If it is on the same site as the first PHP, you could just include the PHP from your first one. Or are you wanting to pass the request information to a php file on a different site? – Dan Sherwin Jun 03 '14 at 04:32
  • if you want to keep track of intermediate data/status, consider using [sessions](http://www.php.net/manual/en/book.session.php) – bansi Jun 03 '14 at 04:34

1 Answers1

0

As @DanSherwin commented, you probably want to use include. You might do something like this:

firstpage.php:

if(/* Some condition when you want to do a redirect */){
    include 'somepage.php';
    exit;
}

This runs the code from somepage.php immediately, as though it was cut and pasted into firstpage.php**, and then it exits right afterward as though you redirected away from firstpage.php.

** caveat: watch out for variable scope.

Community
  • 1
  • 1
pieman72
  • 836
  • 8
  • 14