switch ($_SERVER['HTTP_REFERER']) {
case 'http://domain.com/page1.php':
$referer = 'PAGE #1';
break;
case 'http://domain.com/page2.php':
$referer = 'PAGE #2';
break;
case 'http://domain.com/page3.php':
$referer = 'PAGE #3';
break;
default:
$referer = '';
break;
}
// ...
if ($referer) {
echo 'Вы пришли с ' . $referer;
}