Forum Moderators: coopster
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
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.