Forum Moderators: coopster
when i pass the HTTP_REFERER (either in php or cgi) to a script (such as a 'tell a friend' script) the HTTP_REFERER is always blank, unless i manually deactivate my firewall.
however....
if i click on the 'email a friend' link at the bottom of this very page, the referrer is shown on the next page, even when my firewall is active!
how does brett do it?
[webmasterworld.com...]
Andreas
i have been trying to work around this, so that if no referer is given, then my std url is displayed and sent to the next page:
$fullurl = "{$HTTP_REFERER}";
$stdurl = "http://www.mydomain.com";
if(isset($fullurl))
{
echo "Recommended page: $fullurl<br> " ;
echo"<input type=hidden name=link value=$fullurl>";
}
else
{
echo "Recommended page: $stdurl<br> " ;
echo"<input type=hidden name=link value=$stdurl>";
}
this doesn't work though :-(
any tips for a beginner?
many thanks
<added>
don't worry i've done it. i just check to see if http_referer contains something
if(eregi("http", $HTTP_REFERER))
instead of using isset
cheers
$url = $_SERVER['HTTP_REFERER'] == ''
? 'http://www.ac.com/'
: $_SERVER['HTTP_REFERER'];
echo "Recommended page: $url<br>
<input type=hidden name=link value=$url>";
It tests whether the referrer string is empty or not. If it is it assigns the standard URL to $url. Otherwise it uses the referrer string.
Andreas
This will all depend on the right tools. The modified tagrep script [webmasterworld.com] would enable you to do that very easily.
Andreas
thanks for input,
but i don't understand how i can use this tool to code in the link for each page?
each page would need its own unique link something like mydomain.com/tellfriend.php?myreferringpage.htm. and the php tell a friend script would then use that code to identify the exact page to send.
Thatīs just what the script will do. If you had a website structure like this
/index.html
/ac/index.html
/ac/cds.html
/ac/pix.html
/jmc/index.html
/jmc/pix.html
the script would generate a link in each file that would look like this:
friends.cgi?file=http://www.site.com/index.html
friends.cgi?file=http://www.site.com/ac/index.html
friends.cgi?file=http://www.site.com/ac/cds.html
friends.cgi?file=http://www.site.com/ac/pix.html
friends.cgi?file=http://www.site.com/jmc/index.html
friends.cgi?file=http://www.site.com/jmc/pix.html
if you called it like that:
./tagrep __DOCUMENT_ROOT__/ '^friends.cgi$' \
'sub{(my $n = $File::Find::name) =~ \
s!^__DOCUMENT_ROOT__!http://www.site.com!; \
return "friends.cgi?file=$n";}' href
You would need to replace __DOCUMENT_ROOT__ with your DocumentRoot [httpd.apache.org].
Andreas