By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,853 Members | 2,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,853 IT Pros & Developers. It's quick & easy.

$_SERVER['HTTP_REFERER']; why doesn't it work??

P: n/a
Hi,

I have a script using the $_SERVER['HTTP_REFERER'] var. I now installed
php 5 and this function does not work, 'undefined index' it says. Can
anyone tell me what could be wrong?

Thanks in advance, Maarten

ps. this is not the same server as to which I refered in my other post.

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Muffinman wrote:
I have a script using the $_SERVER['HTTP_REFERER'] var. I now
installed php 5 and this function does not work, 'undefined index' it
says. Can anyone tell me what could be wrong?


It won't be set if no referer information was passed by the browser.

There are three circumstances I can think of when the referer
information is not passed to the browser:

1) The user has typed the address into their browser, clicked a link in
an email client, used a bookmark etc. The referer info will not be set
as they have not been refered from another web page.

2) The user has a browser preference which prevents the referer
information from being passed or uses proxy type software which
prevents this from being passed. (Sometimes this software passes a
referer url but if it does it's usually either the same as the
requested page or the site's homepage and will be the same as they move
from page to page).

3) It's a robot/spider or some script created by the user. These
typically won't pass referer information as they move from page to
page. (Some exceptions are spammy type bots which post a referer url
back to their own site).

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #2

P: n/a
On Sun, 19 Dec 2004 17:26:41 +1300
Chris Hope <bl*******@electrictoolbox.com> wrote:

:Muffinman wrote:
:
:> I have a script using the $_SERVER['HTTP_REFERER'] var. I now
:> installed php 5 and this function does not work, 'undefined index' it
:> says. Can anyone tell me what could be wrong?
:
:It won't be set if no referer information was passed by the browser.

.... and it's not an "error," it's a "notice." The OP can either lower
his error-reporting level:

error_reporting(E_ALL ^ E_NOTICE);

or use isset() to check HTTP_REFERRER before trying to use it.

--
Tony Reed
<tr***@altern.org>
Jul 17 '05 #3

P: n/a
.oO(Tony Reed)
... and it's not an "error," it's a "notice." The OP can either lower
his error-reporting level:

error_reporting(E_ALL ^ E_NOTICE);
Ignoring notices is bad style and may lead to errors that are hard to
find.
or use isset() to check HTTP_REFERRER before trying to use it.


That's how it should be.

Micha
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.