thats because the page which contains the iframe IS the referrer.
the browser first loads the main page, finds an iframe, then it requests that url from your server as well.
you could either
a- just collect the referrer on the main page
b- collect the referrer on the main page, then pass the value to your iframe page
<iframe src="iframe.php?referer=<?php echo $_SERVER['HTTP_REFERRER']; ?>">