473,322 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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
Jul 17 '05 #1
4 6164
Attempting to reach the Kolinahr, Sims wrote:
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


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

/Andreas

--
#Peace and long life ...
Registeret Linux user #292411
Jul 17 '05 #2
>
$_SERVER["HTTP_REFERER"] might be what you are looking for.

/Andreas


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
Jul 17 '05 #3
"Sims" <si*********@hotmail.com> schrieb im Newsbeitrag
news:c6************@ID-162430.news.uni-berlin.de...
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


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
Jul 17 '05 #4
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


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
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: gnah | last post by:
Greetings, I hope my problem is easy to fix, I'm pretty new with php - but I am getting weird results with the opendir() function. It may just be a path problem, but I don't see which variable...
11
by: kk | last post by:
Can any function tell the compiled program executing path? after using the program to open a file from MFC dialog box, the path changes. thks in advance.
11
by: Ken Varn | last post by:
I want to be able to determine my current line, file, and function in my C# application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___ macros for getting this, but I cannot find a...
3
by: PHaroZ | last post by:
Hi, I want to retrieve the complete full path to the directory of my current page but i don't find how to do that. For example i want : D:\myWebSite\firstDotNetWebApp\dir1\ I tried...
15
by: SFX | last post by:
If I have a session ID (string) can I somehow obtain the session object associated to that ID (it exist of course) ? I know this sounds wicked but I have a situation in which I have to make a...
3
by: Poppy | last post by:
Whenever I use "Directory.getcurrentdirectory" I always get "C:\WINDOWS\system32" despite the fact that the code is running from a subdirectory of wwwroot. Can someone help ? How can I get...
31
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I modify the current browser window?...
13
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I am actually trying to get the UNC path of the main module of a process running from a mapped drive, and I am trying to do this from a service. The ProcessModule class only provides the full path...
8
by: =?Utf-8?B?R2VvcmdlQXRraW5z?= | last post by:
Greetings! I wrote a small Exe that simply runs Shell to load PowerPoint and launch a particular file, depending on the day of the week. However, it was set up for office 2003 (I naively hardcoded...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.