[PHP] How can obtain referer's name?
Hi! I want to know how can a script obtain the page name where it was linked. e.g., there's a link on page.html, and the link points to script.php, how can script.php know the name of page.html? Thanks in advance for all answer! Alex -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How can obtain referer's name?
if you have the globals setting in your ini file set to on then you can use: $HTTP_REFERER otherwise, I think, it's found in $_SERVER[HTTP_REFERER] - just check for something like that in phpinfo(); -Original Message- From: Alex Shi [mailto:[EMAIL PROTECTED]] Sent: Monday, May 13, 2002 10:48 AM To: [EMAIL PROTECTED] Subject: [PHP] How can obtain referer's name? Hi! I want to know how can a script obtain the page name where it was linked. e.g., there's a link on page.html, and the link points to script.php, how can script.php know the name of page.html? Thanks in advance for all answer! Alex -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How can obtain referer's name?
At 10:49 AM +1000 13/5/02, Martin Towell wrote: if you have the globals setting in your ini file set to on then you can use: $HTTP_REFERER Watch out though... the HTTP_REFERER data is provided by the user and cannot be trusted. It can't even be guaranteed to exist. If all the pages are on the same site, you could embed the form filename in a hidden field on the form so it is passed to the script. Or since that's also open to abuse by malicious users, you could track where the user is in the site using session variables. ...R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How can obtain referer's name?
if you have the globals setting in your ini file set to on then you can use: $HTTP_REFERER otherwise, I think, it's found in $_SERVER[HTTP_REFERER] - just check for something like that in phpinfo(); Just to be picky, predefined reserved server variables will always exist in both $HTTP_SERVER_VARS and $_SERVER. So, everyone could go through one of these predefined variables regardless of the register_globals value. Of course HTTP_REFERER may or may not exist. And $_SERVER became available in PHP 4.1.0. $HTTP_SERVER_VARS has been around since the 90's :) A related faqt on HTTP_REFERER in PHP can be seen here: Why does $HTTP_REFERER return an empty string? http://www.faqts.com/knowledge_base/view.phtml/aid/31 So regarding the question, do something like so in script.php print $_SERVER['HTTP_REFERER']; print $HTTP_SERVER_VARS['HTTP_REFERER']; Personally I love registering server vars in the scope and many times will do this (on top of the script): if (!ini_get('register_globals')) { extract($HTTP_SERVER_VARS); } In this case, it's safe to use $HTTP_REFERER even if register_globals = off as it will then be created. See also: http://www.php.net/manual/en/language.variables.predefined.php Regards, Philip Olson -Original Message- From: Alex Shi [mailto:[EMAIL PROTECTED]] Sent: Monday, May 13, 2002 10:48 AM To: [EMAIL PROTECTED] Subject: [PHP] How can obtain referer's name? Hi! I want to know how can a script obtain the page name where it was linked. e.g., there's a link on page.html, and the link points to script.php, how can script.php know the name of page.html? Thanks in advance for all answer! Alex -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php