469,281 Members | 2,489 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,281 developers. It's quick & easy.

Unable to use $_SERVER['HTTP_REFERER']

Jez
Any ideas why I'm not able to use $_SERVER['HTTP_REFERER'] on my
shared hosting account (PHP 4.1.2), but I can on my local server (PHP
4.3.3)?

I imagine it has something to do with the different versions of PHP or
perhaps php.ini, but I'm not sure what?

Thanks!

Jez
Jul 17 '05 #1
9 30638
On Mon, 06 Oct 2003 23:56:31 -0700, Jez wrote:
Any ideas why I'm not able to use $_SERVER['HTTP_REFERER'] on my
shared hosting account (PHP 4.1.2), but I can on my local server (PHP
4.3.3)?

I imagine it has something to do with the different versions of PHP or
perhaps php.ini, but I'm not sure what?


Have you tried adding a quick phpinfo(); to your script to make sure that
the hosting web server is actually providing the referer information?

/Ant

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 17 '05 #2
Jez
je**********@btinternet.com (Jez) wrote in message news:<ad**************************@posting.google. com>...
Any ideas why I'm not able to use $_SERVER['HTTP_REFERER'] on my
shared hosting account (PHP 4.1.2), but I can on my local server (PHP
4.3.3)?

I imagine it has something to do with the different versions of PHP or
perhaps php.ini, but I'm not sure what?

Thanks!

Jez


The reason I ask is that I've created a 'send to friend' page which
obviously needs to know the url of the referring page.

I've found a solution, but I'm unsure whether it's ok to use:

Rather than use $_SERVER['HTTP_REFERER'] on the 'send to friend' page,
I've used send.php?page=http://$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']
in the link on the referring page.

It works, and although it's not the best solution is it a good one?

Jez
Jul 17 '05 #3

On 6-Oct-2003, je**********@btinternet.com (Jez) wrote:
Any ideas why I'm not able to use $_SERVER['HTTP_REFERER'] on my
shared hosting account (PHP 4.1.2), but I can on my local server (PHP
4.3.3)?

I imagine it has something to do with the different versions of PHP or
perhaps php.ini, but I'm not sure what?


The browser may choose not to provide referer information.

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)
Jul 17 '05 #4

"Jez" <je**********@btinternet.com> wrote in message
news:ad**************************@posting.google.c om...
Any ideas why I'm not able to use $_SERVER['HTTP_REFERER'] on my
shared hosting account (PHP 4.1.2), but I can on my local server (PHP
4.3.3)?

I imagine it has something to do with the different versions of PHP or
perhaps php.ini, but I'm not sure what?

Thanks!

Jez


The browser might not provide HTTP_REFERER so you cannot rely on it -
Secondly, some software firewalls (like Norton Internet Security) have
features to strip out such information... It might work on your local server
if your local server is also your client....
Jul 17 '05 #5
"Jez" <je**********@btinternet.com> wrote in message
news:ad**************************@posting.google.c om...
Any ideas why I'm not able to use $_SERVER['HTTP_REFERER'] on my
shared hosting account (PHP 4.1.2), but I can on my local server (PHP
4.3.3)?


Just print it out to the browser:

print '<pre><xmp>';
print_r($_SERVER);
print '</xmp></pre>';

and you see which keys are defined inside $_SERVER @ your hoster.

regards

timo

Jul 17 '05 #6
Jez wrote:
je**********@btinternet.com (Jez) wrote in message news:<ad**************************@posting.google. com>...
Any ideas why I'm not able to use $_SERVER['HTTP_REFERER'] on my
shared hosting account (PHP 4.1.2), but I can on my local server (PHP
4.3.3)?

I imagine it has something to do with the different versions of PHP or
perhaps php.ini, but I'm not sure what?

Thanks!

Jez

The reason I ask is that I've created a 'send to friend' page which
obviously needs to know the url of the referring page.

I've found a solution, but I'm unsure whether it's ok to use:

Rather than use $_SERVER['HTTP_REFERER'] on the 'send to friend' page,
I've used send.php?page=http://$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']
in the link on the referring page.

It works, and although it's not the best solution is it a good one?


That's about as reliable as you're gonna get. Not all browsers/web
servers provide referer info, and still others allow you to set it to
whatever you want.

That said, you may not want to provide the entire URL to the send.php
script. Use only the REQUEST_URI, and put that in a session variable
instead of a get request. Not doing these things may cause you pain when
spammers see how easy it will be to use your script for themselves...

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

Jul 17 '05 #7
Jez
Anthony Whitehead <an***************@rfv.sfa.se> wrote in message news:<pa****************************@rfv.sfa.se>.. .
On Mon, 06 Oct 2003 23:56:31 -0700, Jez wrote:
Any ideas why I'm not able to use $_SERVER['HTTP_REFERER'] on my
shared hosting account (PHP 4.1.2), but I can on my local server (PHP
4.3.3)?

I imagine it has something to do with the different versions of PHP or
perhaps php.ini, but I'm not sure what?


Have you tried adding a quick phpinfo(); to your script to make sure that
the hosting web server is actually providing the referer information?


Thanks.

Just tried it and it's not listed. Does that mean it's a server issue
rather than a PHP one?

Jez
Jul 17 '05 #8
Jez
je**********@btinternet.com (Jez) wrote in message news:<ad**************************@posting.google. com>...
je**********@btinternet.com (Jez) wrote in message news:<ad**************************@posting.google. com>...
Any ideas why I'm not able to use $_SERVER['HTTP_REFERER'] on my
shared hosting account (PHP 4.1.2), but I can on my local server (PHP
4.3.3)?

I imagine it has something to do with the different versions of PHP or
perhaps php.ini, but I'm not sure what?

Thanks!

Jez


The reason I ask is that I've created a 'send to friend' page which
obviously needs to know the url of the referring page.

I've found a solution, but I'm unsure whether it's ok to use:

Rather than use $_SERVER['HTTP_REFERER'] on the 'send to friend' page,
I've used send.php?page=http://$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']
in the link on the referring page.

It works, and although it's not the best solution is it a good one?

Jez


Perhaps $_SERVER['SCRIPT_URI'] would be more appropriate?
Jul 17 '05 #9
"Timo Henke" <we*******@fli7e.de> wrote in message
news:bl*************@news.t-online.com...
"Jez" <je**********@btinternet.com> wrote in message
news:ad**************************@posting.google.c om...
Any ideas why I'm not able to use $_SERVER['HTTP_REFERER'] on my
shared hosting account (PHP 4.1.2), but I can on my local server (PHP
4.3.3)?


Just print it out to the browser:

print '<pre><xmp>';
print_r($_SERVER);
print '</xmp></pre>';

and you see which keys are defined inside $_SERVER @ your hoster.


It could be related to your browser. Most firewall products will block the
sending of the HTTP_REFERER information to untrusted sites. If you can't
read HTTP_REFERER during testing, try turning your firewall off as it may
make a difference. Firewalls create a lot of problems for users and they
often blame the web developer for cookie problems, HTTP_REFERER issues and
spurious JavaScript errors when its the firewall's interference that has
caused the errors to occur. You can, and should, program around cookie and
REFERER issues but the JavaScript errors are moderately difficult to code
around unless you start using sneaky tactics. Such tactics for legitimate
purposes seem a bit bizarre but Symantec and ZoneAlarm create a significant
number of support issues through their default settings.

Paulus
Jul 17 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Krzysztof Piotrowski | last post: by
3 posts views Thread by Muffinman | last post: by
2 posts views Thread by ssk | last post: by
17 posts views Thread by windandwaves | last post: by
22 posts views Thread by walterbyrd | last post: by
8 posts views Thread by e_matthes | last post: by
3 posts views Thread by ojorus | last post: by
8 posts views Thread by mrsmithq | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.