‘HTTP_REFERER’
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
As igor_g says, HTTP_REFERER can’t really be trusted and won’t always be set (eg. if the user arrives directly at the page) but if you want to use it it’s best to check if it’s set first. The ‘Undefined index’ notice you quote is because it’s not set, so use something like this:
As for why you’re seeing the Notice in the page source but not the page, perhaps the browser is re-requesting a fresh copy of the page when you view the source.