Connecting Tech Pros Worldwide Help | Site Map

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

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 04:58 AM
Sims
Guest
 
Posts: n/a
Default How can i get my current full path? (and use it in the header)

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, 04:58 AM
Andreas Paasch
Guest
 
Posts: n/a
Default 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, 04:58 AM
Sims
Guest
 
Posts: n/a
Default 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, 04:58 AM
Markus Ernst
Guest
 
Posts: n/a
Default 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, 04:59 AM
Sims
Guest
 
Posts: n/a
Default 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


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.