Well i know its using the $_SERVER command, but i've been looking on the web and most sites just tell me its crap. I only want it for a simple job, basically if they came from logout.php , echo "You are now logged out" above the login form..
So, how do i get the URL in which they came from? Cos i obv dont want the message displayed if theycame from index.php.
Thanks!
Calling URL - How?
Moderator: General Moderators
Re: Calling URL - How?
If you are just trying to find the URL of the page from which the user came, you should be able to use $_SERVER['HTTP-REFERER']. See http://us2.php.net/manual/en/reserved.v ... server.php.
However, I don't think this is what you really want to do. If you have a logout.php script, that script, once visited, should probably just unset any $_SESSION variables you have set to maintain state. Or, if you're using cookies directly, the logout.php script should just destroy those cookies.
Not sure exactly what you want to do and/or how you're doing everything else, but I think you should look into $_SESSION variables.
However, I don't think this is what you really want to do. If you have a logout.php script, that script, once visited, should probably just unset any $_SESSION variables you have set to maintain state. Or, if you're using cookies directly, the logout.php script should just destroy those cookies.
Not sure exactly what you want to do and/or how you're doing everything else, but I think you should look into $_SESSION variables.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Calling URL - How?
$_SERVER['HTTP_REFERER'] should never be relied upon. It is up to the user client to send it's referal url, and is often blocked or manipulated to protect the users privacy. Instead, as chopsmith suggested, store the last visited page in a session variable.chopsmith wrote:If you are just trying to find the URL of the page from which the user came, you should be able to use $_SERVER['HTTP-REFERER']. See http://us2.php.net/manual/en/reserved.v ... server.php.
However, I don't think this is what you really want to do. If you have a logout.php script, that script, once visited, should probably just unset any $_SESSION variables you have set to maintain state. Or, if you're using cookies directly, the logout.php script should just destroy those cookies.
Not sure exactly what you want to do and/or how you're doing everything else, but I think you should look into $_SESSION variables.