Forum Moderators: coopster

Message Too Old, No Replies

name of script that called this script

looking for php function that gives me the script name that called this one

         

syndeticFT

1:21 am on Feb 7, 2005 (gmt 0)

10+ Year Member



I have a simple user authentication program

The first line of any script is
include ('../user_management/check_valid_user.php'); // stops & tells user to login if not a valid user.

If the person is known in my user data base then the script continues.
If the person is not logged in it redirects to a login script.

The problem is that the login script does not know where to come back to. AT present I have one version of check_valid_user.php for each application that I have written.

What I would like is to find a php function that can tell me the name of the script that called check_valid_user.php.

Alternatively a function that can tell me the name of the script that I am currently running and then I will pass that to check_valid_user.php as a variable.

Thanks, Frank

kpaul

1:40 am on Feb 7, 2005 (gmt 0)

10+ Year Member



try:

$HTTP_SERVER_VARS["REQUEST_URI"];

i ran into this a while back and blogged it after realizing how hard it was to search for the concept ;)

HTH
-kpaul

coopster

12:08 pm on Feb 7, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, syndeticFT.

I use REQUEST_URI to find out which link was clicked or keyed into the address bar as well. If you are going to redirect to a login page and want to return the user to the original page requested, the typical approach is to push the requested page into a SESSION variable and use that to return the user to the requested page after authentication.

if (user not authenticated) { 
$_SESSION['page_requested'] = $_SERVER['REQUEST_URI'];
header("Location: http://example.com/mylogin");
exit;
}
I'm assuming you have already started your session by this point of course.

syndeticFT

9:10 pm on Feb 7, 2005 (gmt 0)

10+ Year Member



Thanks

The suggestions have worked perfectly.

Frank