Forum Moderators: coopster

Message Too Old, No Replies

Getting HTTP_REFERER of top/parent document in PHP

possible?

         

ngentot

10:18 am on Dec 12, 2004 (gmt 0)



I'm trying to build a tracking code on a page using an image call that looks like something like this:

<img src=http://www.domain/script.php width=1 height=1>

The problem is when I try to access the HTTP_REFERER, I get the URL of the current document that contains this image call, not the one of the previous document that called this document.

Is there a way to get this in PHP? Something like top.referer or parent.referer in Javascript. BTW, I cannot use Javascript for this tracking scheme.

Thanks.

Patrick Taylor

11:07 am on Dec 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I may have misunderstood what you're trying to do, but instead of using an image, why not use


if (isset($_SERVER['HTTP_REFERER'])) {
$refer = $_SERVER['HTTP_REFERER'];
}

then record $refer as the referrer?

mykel79

5:49 pm on Dec 12, 2004 (gmt 0)

10+ Year Member



I'm afraid you'd have to add the referring url as a parameter when calling the image (using javascript). Something like:

<script language="JavaScript">
<!--
document.write('<img src="http://www.domain/script.php?ref='+document.referrer+'">');
//-->
</script>

ngentot

5:37 am on Dec 13, 2004 (gmt 0)



Patrick..oops sorry I forgot to mention that the webpage I'm trying to track is not on my server, but on someone else's website that lets me posts a message like on this webmasterworld. So I can't add any PHP (or Javascript for this matter) to the page.

mykel... any other way without using Javascript?