When u know the user is not logged in and you have to redirect him to
login page, get all variables that are in $_GET and in $_POST (if u have
data that u send in post also) and form a string with them as a return
context string like:
The code that you have to put in the page where you redirect the user to
login page and where user will land back after login.
$return_context = $PHP_SELF."?";
foreach( $_GET as $key => $val )
$return_context .= "&".$key."=".$val;
foreach( $_POST as $key => $val )
$return_context .= "&".$key."=".$val;
header( "Location: login.php?back_page=".urlencode( utf8_encode(
$return_context ) ) );
In login page, after you created the session or whatever you do at login
pagrt you do:
if( empty( $back_page ) )
$back_page = $_GET["back_page"];
if( !empty( $back_page ) )
header( "Location: ".utf8_decode( urldecode( $back_page ) ) );
else
header( "Location: somewhere_else.php" );
exit;
The code is not checked. It's only to have an ideea...
Andy
Sjef wrote:
> Hello all!
> This is a bit difficult to explain.
> On a site I am building I sometimes use the GET method to forward values to
> the next page. There are certain pages that you need to be logged in to to
> be able to see data. So you arrive at the page, you realize that you are not
> logged in, so you type your username/password and hit 'log in'. Then the
> page gets severely messed up as the GET data are not forwarded (at least, I
> think that's the problem). Any ideas how to solve this?
> I tried to send a header("location: ...") with the document_root and
> request_uri as the location, but that doesn't do the trick.
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php