$_server['http_referrer'] problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
RedRasper
Forum Commoner
Posts: 48
Joined: Thu Apr 24, 2003 6:36 am

$_server['http_referrer'] problem

Post by RedRasper »

Hi,

Can someone help me. I have no idea why I keep getting this error, as as far as I can find out the syntax is correct.

header("Location: $_SERVER['HTTP_REFERER']");

The error I get is:

PHP Notice: Undefined index: 'HTTP_REFERER' in c:\apache\apache2\htdocs\TMP6yxo8e5lhx.php on line 7.

Thank you to anyone who can help!


RedRasper
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Basically, a value for HTTP_REFERER hasn't been set - you could test to see if the information exists and redirect to a default page if it hasn't:

Code: Select all

$redirect_url = (!empty($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : 'http://www.mysite.com/default.php';
header("Location: $redirect_url");
Mac
Post Reply