If your application absolutely depends on knowing what the 'referring page' was, then using sessions is the best answer. As dagon points out, the $_SERVER['HTTP_REFERER'] variable isn't reliable, since the Referer HTTP header is not only optional but completely un-verified/sanitized.
As for the solution, here's one possibility:
$referrer = preg_replace('/\?.*/', '', $_SERVER['HTTP_REFERER']);