Solved

referer

Posted on 2009-04-08
2
157 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

809 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