473,383 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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

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
3 7933
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
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
.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Jez | last post by:
Any ideas why I'm not able to use $_SERVER 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...
1
by: Krzysztof Piotrowski | last post by:
Hi all, I hale recently started using php - god fun :-D I decided to make visits statistics. My webpage http://www.kolumb.net/ has a statistic at http://www.kolumb.net/mysql/list_stats.php ...
9
by: deko | last post by:
I have a page that I don't want anyone to be able to link directly to. The page should only be accessed from gatepage.php. I tried this code, but keep getting errors - "header info already sent",...
2
by: ssk | last post by:
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. ...
17
by: windandwaves | last post by:
Hi Folk I am reading the info below and I am thinking, just how trusted is it. I have a redirection in place using an .htaccess file. The file it redirects to is 404.php. Is there a way to...
22
by: walterbyrd | last post by:
I like to develop on my desktop, then when I get stuff working, I copy to my web-site. I set up a new version Xampp on my windows-2k desktop. And downloaded the stuff from the website to edit....
8
by: e_matthes | last post by:
Hello, I keep reading that $_SERVER can easily be faked. Is that true of all server variables, or just some of them? In particular, I'm wondering if server_port can be faked. I'm interested...
3
by: ojorus | last post by:
Hi! I'm using $_SERVER to see which site the visitors on my site is coming from. It works OK, but as we all now, not all sites give http_referer a value, i.e. miniclip.com. What I DON'T...
8
by: mrsmithq | last post by:
I have a page that has this logic in it: //We can call it access.php if (!isset($_SESSION)){ header("Location:index.php"); exit(); } //Here is the index.php echo "<br>" . $_SERVER;
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.