I need someone to make me a site that will show a special message only to people that come from x site.
<?php
$ref_site = "referringsite.com";
if(isset($_SERVER['HTTP_REFERER'])){if(strstr($_SERVER['HTTP_REFERER'],$ref_site)){echo "You Visited Us From ".$ref_site;}}
?>
What if the refering site is facebook or some other social media it will still work. Can i add multiple referer cuz fb may send the traffic as l.facebook.com or m.facebook.com. ThanksJust add this code where you want the message shown:
PHP:<?php $ref_site = "referringsite.com"; if(isset($_SERVER['HTTP_REFERER'])){if(strstr($_SERVER['HTTP_REFERER'],$ref_site)){echo "You Visited Us From ".$ref_site;}} ?>
What if the refering site is facebook or some other social media it will still work. Can i add multiple referer cuz fb may send the traffic as l.facebook.com or m.facebook.com. Thanks
<?php
$ref_sites = array("referringsite.com", "referringsite2.com", "referringsite3.com");
$allowed=0;
if(isset($_SERVER['HTTP_REFERER'])){
foreach($ref_sites as $ref_site){
if(strstr($_SERVER['HTTP_REFERER'],$ref_site)){$allowed=1;break;}
}
}
if($allowed==1){
echo "You Visited Us From ".$ref_site;
}
?>