Reputation: 18200
Let's say I have a PHP file disguised as an image. Anyways, I want to log all of the clicks from it and where it was clicked it.
Right now, I'm using http://www.webcheatsheet.com/PHP/get_current_page_url.php but does not help. All I get is where the image is HOSTED on. I want where the image is clicked from... like where on the web was that image found, you know?
Upvotes: 1
Views: 480
Reputation: 163234
As esqew commented, you need to check the referrer with $_SERVER['HTTP_REFERRER']
. The reason that the current page URL doesn't get what you want, is because the current page would be that image script of yours.
You should note though that the client doesn't have to submit a referrer. In most cases it will, but it is not required to. Furthermore, there may not even be a referrer if the image is accessed directly.
Finally, do not rely on that referrer for any sort of security, as it can be easily changed by the client.
Upvotes: 2