Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

referer

Posted on 2009-04-08
2
Medium Priority
?
162 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

636 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