I believe $_SERVER['HTTP_REFERRER'] does this no?
From the manual:
'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.
As to pass the variables from a form, you can loop through the POST global variable since it stores the data into an array.