Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

referer question

Status
Not open for further replies.

riffy

Programmer
Mar 29, 2001
106
0
0
US
Hi guys,

I have a page in which I'm checking to see if the user came through the referring page or not.

$HTTP_REFERER = '$referer = $HTTP_REFERER;
if (!($referer)) {
header ("Location: emailcheck.php");
exit;
}
else {

process page

}

however, it's not even reading that script and automatically loads the page.

my question is where do i specify the referrer url and how will the code work?

thanks
Arif
[yoda]
 
Change the line:
if (!($referer)) {
To;
if (!$referer) {
and you should be up and running in no time!!
 
it didn't work smashing

it's like it's not even reading that line, the page just loads as if there is no check for referer
 
Umm... You basically assign a value to the [tt]$HTTP_REFERER[/tt] variable, assign that to the [tt]$referer[/tt] variable, and then check if that is false. It will never be false, since you assign it in your code.

//Daniel
 
All you do is making assignments here using the single =.

To compare strings for being equal you need to use ==.

I also don't understand why you assign the string for the $HTTP_REFERER, you actually destroy the information the server provided.

What you want to do is more like this:
Code:
$allowed = "[URL unfurl="true"]http://www.myhost.com/myurl";[/URL]
if ($HTTP_REFERER == $allowed){
  # proceed
} else {
  # check or kick them out
}
If you want to turn it around and make an 'unequal' comparison:
Code:
$allowed = "[URL unfurl="true"]http://www.myhost.com/myurl";[/URL]
if ($HTTP_REFERER != $allowed){
  # check them or kick them out
} else {
  # proceed
}

OK? Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top