Finding the Referrer for a 404 Page? Deprecated code?

I have ported a drupal 6 install over to a new drupal7. My custom 404 page allowed the user to report where the external referrer had the dead, missing, or changed link. However, now the page is sporting an error and I don’t know if it is because the php code is deprecated or some other issue with a new php install.

I was hoping for a little help here, because the error I get also points to a base module php.php file, but I don’t think it is related directly:

[b][i]Notice: Undefined variable: HTTP_REFERER in eval() (line 13 of /usr/home/ user/public_html/website.com/modules/php/php.module(82) : eval()'d code)[/i][/b]

The module line is simply a function called admin help. My current version is PHP Version 5.6.16

This is the code on the page

  [php]  <input name="error" type="text" id="errorlink" value="<?php echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];?>" size="50"> <input name="errorlink" type="hidden" value="<?php echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];?>"></p>
    <br><input name="referringLink" type="hidden" value="<?php echo  $HTTP_REFERER?>"></code>[/php]

TIA,
Jeff

I think you can just change $HTTP_REFERER to $_SERVER[‘HTTP_REFERER’]

[php]



<input name=“referringLink” type=“hidden” value="<?php echo $_SERVER['HTTP_REFERER']?>"
[/php]

Thanks… I’m not seeing the error on the page anymore, but it isn’t getting the external referring page in the error field…

http://scholarscorner.com/badlinkpage For example, if I click this link here, the referrer should recognize this page as the source of the bad link… It reports the bad link, but not the external referrer…

(I can’t post the link… haven’t been here long enough, so it won’t work )…

I think you need 10 posts to be able to post a link, but I’m sure you can get creative.

Well, sometimes the referrer is not available. Here is a quote from a site discussing this subject:

Most web browsers pass the HTTP_REFERER variable by default, but in many this behaviour can be changed to not show it or to pass something else instead. There is also 3rd party anti-spyware etc software that can be installed on a user's computer which also prevents the referrer information from being passed to the web server. Because it can also be changed to something else, the HTTP_REFERER cannot be trusted, but it is still useful for working out where people have come from.
They suggest using this to handle it:
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'Referer not available!';

You can read the article here:
http://www.electrictoolbox.com/php-http-referer-variable/

Not that this really helps your issue, but more info is always handy…

Sponsor our Newsletter | Privacy Policy | Terms of Service