fai attenzione che $_SERVER['HTTP_REFERER'] non è sempre affidabile, in quanto è possibile alterarlo via browser.