Solved

referer

Posted on 2009-04-08
2
156 Views
Last Modified: 2012-05-06
hello there im trying to show if there was a referer but if there is none im getting an error

Notice: Undefined index: HTTP_REFERER in test.php on line 1
if ($_SERVER['HTTP_REFERER'] != "") {
	$ref=$_SERVER['HTTP_REFERER'];
}
 
if(eregi('sitename', $ref)) {
	echo 'good';
}else{
	echo 'bad';
}

Open in new window

0
Comment
Question by:XK8ER
  • 2
2 Comments
 
LVL 10

Expert Comment

by:Phatzer
ID: 24100998
Replace:

if ($_SERVER['HTTP_REFERER'] != "") {

with:

if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != "") {
0
 
LVL 10

Accepted Solution

by:
Phatzer earned 500 total points
ID: 24101009
In fact, do it like this:
if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != "") {
        $ref=$_SERVER['HTTP_REFERER'];
} else {
        $ref=null;
}
 
if(eregi('sitename', $ref)) {
        echo 'good';
}else{
        echo 'bad';
}

Open in new window

0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question