FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Referer





Diablosblizz
I'm having some troubles with a PHP referer. I am using the code below:

Code:
<?php
$ref = $_SERVER['HTTP_REFERER'];

if(!$ref == "somesite") {
echo "No access!";
} else if($ref == "somesite") {
echo "Access!";
}

echo $ref

?>


If I try that on Frihost, setup a a href to go to the page nothing happens. I get a blank. Is there something disabled on Frihost that doesn't allow referers? Thanks for the information!
rvec
Code:
if($ref != "somesite") {

That should work. And it's not frihost that would block that (if it's blocked), it'd more likely be blocked on the client side.
imagefree
one thing to note! if the link on which you click (the referer link) is on a local page (with url like: file://localhost/C:/...), no referer information is sent by the browser (may be for security reasons).

You should use ini_set('error_reporting', E_ALL | E_NOTICE); at the top of your script, and if the referer information is not sent, and you try to echo it, it will produce notice. Check and tell us.
sonam
Try something like this.

Code:
<?php
$ref = $_SERVER['HTTP_REFERER'];

if(empty($ref) || $ref != "somesite") {
echo "No access!";
exit;
} elseif($ref == "somesite") {
echo "Access!";
}

echo $ref;

?>


Sonam
Diablosblizz
I have apache on my server and going from one page to another (on the SAME server) still doesn't show the $ref variable. Even tried all the suggestions, no error but just the warning message saying no access.
rvec
try this:
Code:
if (isset($_GET['ref'])){var_dump($_SERVER['HTTP_REFERER']);}else{echo '<a href="?ref=1">clickme</a>';}

if you get nothing there something is wrong with your browser or server.
Diablosblizz
Hmm, now that you say that something could be wrong with your browser could some browsers not send the referer? If browsers can turn off this feature then this is useless.

By the way, it works! Thanks!
rvec
most browsers don't, but for example firefox has a plugin to edit the headers you send to the server and maybe some exotic browsers don't support it at all.
Related topics
dot files
Problam about google ad code
Fantastico could be updated
.htaccess IP Blocking
I just got me a com domain for my site check it out !
the new eminem video clip
Site Nav Suggestions...
'Where To' For Domain Name Registration?
creating .htaccess?
Referals?
Image Magick on vacation?
Do you want a free domain?
C++ pointers
Web Protect
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.