on the site when an image is required the link is like this
<img src="getimage.php?id=<?php echo $name ?>" " width="280px" height="70px">
Then on getimage.php it gets the id and from that finds the right picture and displays it.
$id = $_GET['id'];
This works perfectly. How would I find out where the request came from. So on which page this line below was on
<img src="getimage.php?id=<?php echo $name ?>" "width="280px" height="70px">
So ultimately I can know if the image requested is for index.php or about.php etc
Thanks
You can add an additional parameter to the image URL that specifies from which page it was requested:
Works exactly like how you did it with the
idparameter.The benefit is, this does not rely on some headers browsers send (or not) like the HTTP Referer, something you have no control over from server-side.
To obtain the page the image-link is generated on, you can use something like this:
See
basenamePHP Manual and__FILE__PHP Manual.Additionally, the code makes use of the
urlencodePHP Manual function to ensure that the attribute doesn’t break.