Look into the global variable $_SERVER['HTTP_REFERER']
, which may fill your needs. However, as the manual mentions, it can't really be trusted.
Much better would be to pass a value via the query string. That would require changing all the links though... and can be modified by the user. Though I'm not sure anyone would bother.