first of all, you need to be coming from another page to be able to use $HTTP_REFERER. so first make a plain html page with a link on it to your script. then, click the link to go to your script. just make the script real simple to test:
<?
print $HTTP_REFERER;
?>
if that doesn't work, try this:
<?
$ref = getenv($HTTP_REFERER);
print $ref;
?>
make sure that you are starting from the html page and clicking on the link to get to the script or the variable will be empty.