kinda don't really understand you but i think you want this, it is a server variable to check where someone came from, it can be fooled/spoofed/etc... fairly easily so beware...
echo $_SERVER['HTTP_REFERER']; // will get you what you want
'HTTP_REFERER'
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.