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

Question about $HTTP_HOST, $HTTP_REFERER

P: n/a
ssk
Hello!

I made a web site using PHP Open sources for message board.
Everything's fine except one computer can't open a message writing
page.

The code that gives an error is the following.

if(!eregi($HTTP_HOST,$HTTP_REFERER)) Error("Write in the normal way");

The browser is IE 6.0 and I configured the options the same as other
computer.

What's wrong?

TIA.
Sam

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


P: n/a
ss*@chol.net wrote:
I made a web site using PHP Open sources for message board.
Everything's fine except one computer can't open a message writing
page.

The code that gives an error is the following.

if(!eregi($HTTP_HOST,$HTTP_REFERER)) Error("Write in the normal way");

The browser is IE 6.0 and I configured the options the same as other
computer.

What's wrong?


Possibly the HTTP_REFERER variable isn't being set. Is there something
on that computer which might be prevented the referal information being
passed?

As an aside, you are better to use the $_SERVER superglobal array like
so: $_SERVER['HTTP_HOST'] and $_SERVER['HTTP_REFERER'] as the use of
$HTTP_HOST etc has been deprecated.

You can never rely on $_SERVER['HTTP_REFERER'] being set so it is
generally unsafe to rely on it. There are browser preferences and other
3rd party apps that can prevent it being passed or otherwise altered.

When using HTTP_REFERER you are best to check it is first set with the
isset() function eg

if(isset($_SERVER['HTTP_REFERER'])) {
...
}
else {
...
}

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

P: n/a
*** ss*@chol.net escribió/wrote (1 Feb 2005 08:53:56 -0800):
I made a web site using PHP Open sources for message board.
Everything's fine except one computer can't open a message writing
page.

The code that gives an error is the following.

if(!eregi($HTTP_HOST,$HTTP_REFERER)) Error("Write in the normal way");


Two remarks. First of all, the preferred way to call these variables is
using the $_SERVER array:

$_SERVER['HTTP_HOST']
$_SERVER['HTTP_REFERER']

Secondly, there's most likely an ad-blocking software or firewall that
removes the referrer header from browser requests.
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Manda tus dudas al grupo, no a mi buzón
-+ Send your questions to the group, not to my mailbox
--
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.