Connecting Tech Pros Worldwide Help | Site Map

How can i get my current full path? (and use it in the header)

  #1  
Old July 17th, 2005, 05:58 AM
Sims
Guest
 
Posts: n/a
Hi,

I have a few 'secure' area where the user needs to log-in b4 they can make
view it.
I know how to redirect them to the login page but how can I return them to
the page they were?

if I get the path ...and save it, (in a cookie or in MySQL ).

$ReturnUrl = $_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING'];

the path is relative to the root directory,
(http://uk.php.net/reserved.variables).

And then try and use it (b4 all the headers are sent).

header( 'refresh: 20; url='.$ReturnUrl );

It does not work properly, ( the query strings is truncated). if I place it
in quotes then the system adds http:\\ in the string.

What is the best way to return to a page full path, (including the query
string).

Many thanks Sims


  #2  
Old July 17th, 2005, 05:58 AM
Andreas Paasch
Guest
 
Posts: n/a

re: How can i get my current full path? (and use it in the header)


Attempting to reach the Kolinahr, Sims wrote:
[color=blue]
> Hi,
>
> I have a few 'secure' area where the user needs to log-in b4 they can make
> view it.
> I know how to redirect them to the login page but how can I return them to
> the page they were?
>
> if I get the path ...and save it, (in a cookie or in MySQL ).
>
> $ReturnUrl = $_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING'];
>
> the path is relative to the root directory,
> (http://uk.php.net/reserved.variables).
>
> And then try and use it (b4 all the headers are sent).
>
> header( 'refresh: 20; url='.$ReturnUrl );
>
> It does not work properly, ( the query strings is truncated). if I place
> it in quotes then the system adds http:\\ in the string.
>
> What is the best way to return to a page full path, (including the query
> string).
>
> Many thanks Sims[/color]

$_SERVER["HTTP_REFERER"] might be what you are looking for.

/Andreas

--
#Peace and long life ...
Registeret Linux user #292411


  #3  
Old July 17th, 2005, 05:58 AM
Sims
Guest
 
Posts: n/a

re: How can i get my current full path? (and use it in the header)


>[color=blue]
> $_SERVER["HTTP_REFERER"] might be what you are looking for.
>
> /Andreas
>[/color]

According to the manual that value might not be set. So I cannot rely on it.

"HTTP_REFERER

The address of the page (if any) which referred the user agent to the
current page. This is set by the user agent. Not all user agents will set
this, and some provide
the ability to modify HTTP_REFERER as a feature. In short, it cannot really
be trusted."

http://uk.php.net/reserved.variables

Sims


  #4  
Old July 17th, 2005, 05:58 AM
Markus Ernst
Guest
 
Posts: n/a

re: How can i get my current full path? (and use it in the header)


"Sims" <siminfrance@hotmail.com> schrieb im Newsbeitrag
news:c6ikdh$c6enj$1@ID-162430.news.uni-berlin.de...[color=blue]
> Hi,
>
> I have a few 'secure' area where the user needs to log-in b4 they can make
> view it.
> I know how to redirect them to the login page but how can I return them to
> the page they were?
>
> if I get the path ...and save it, (in a cookie or in MySQL ).
>
> $ReturnUrl = $_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING'];
>
> the path is relative to the root directory,
> (http://uk.php.net/reserved.variables).
>
> And then try and use it (b4 all the headers are sent).
>
> header( 'refresh: 20; url='.$ReturnUrl );
>
> It does not work properly, ( the query strings is truncated). if I place[/color]
it[color=blue]
> in quotes then the system adds http:\\ in the string.
>
> What is the best way to return to a page full path, (including the query
> string).
>
> Many thanks Sims
>[/color]

I usually do things like that without a login page but by including the
login form into every page that requires login:

<?php

$logged = false;

if(isset($_POST['login'])) {
if([check for correct username and password here]) {
[write cookie here];
$logged = true;
}
else {
$message = "Incorrect login, try again!";
$logged = false;
}
}

else if([check for cookie]) {
$logged = true;
}

?>
<html>
<head>
</head>
<body>
[put navigation or whatever comes before the contents here]
<div id="contents">
<?php

if(!$logged) {
if(isset($message)) echo "<p><strong>".$message."</strong></p>";
include("myloginform.php");
}

else {
?>
[put page contents here]
<?php
}
?>
</div>
[put footer or whatever comes after the contents here]
</body>
</html>

Like that you don't have redirection problems, and the user that does not
have access to the protected area will not be taken out of his navigation
flow.

HTH
Markus


  #5  
Old July 17th, 2005, 05:59 AM
Sims
Guest
 
Posts: n/a

re: How can i get my current full path? (and use it in the header)


[color=blue][color=green]
> > Hi,
> >
> > I have a few 'secure' area where the user needs to log-in b4 they can[/color][/color]
make[color=blue][color=green]
> > view it.
> > I know how to redirect them to the login page but how can I return them[/color][/color]
to[color=blue][color=green]
> > the page they were?
> >
> > if I get the path ...and save it, (in a cookie or in MySQL ).
> >
> > $ReturnUrl = $_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING'];
> >
> > the path is relative to the root directory,
> > (http://uk.php.net/reserved.variables).
> >
> > And then try and use it (b4 all the headers are sent).
> >
> > header( 'refresh: 20; url='.$ReturnUrl );
> >
> > It does not work properly, ( the query strings is truncated). if I place[/color]
> it[color=green]
> > in quotes then the system adds http:\\ in the string.
> >
> > What is the best way to return to a page full path, (including the query
> > string).
> >
> > Many thanks Sims
> >[/color]
>[/color]

Thanks all for the replies,

Just as an aside, the reason my header(... ) was not working was because I
was replacing the '&' with the html equivalent &amp;

Sims


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
"error_reporting" setting not being recognized in my php.ini file laredotornado@zipmail.com answers 1 October 3rd, 2006 03:25 PM
Can't make this page work scottyman@comcast.net answers 6 March 9th, 2006 04:25 AM
Why must I use PrtDevMode Randy Harris answers 5 November 12th, 2005 04:11 PM
crossplatform py2exe - would it be useful? Thomas Heller answers 20 July 18th, 2005 02:26 AM