This is false PHP! Don't try to run this code as it is because it will certainly not work. I wrote it just to give you an idea:
if (everything == OK)
{sendheaders ();}
// I mean, the GOOD headers!
else
{header("HTTP/1.0 404 Not Found");
include ("beautifully_crafted_error_page.inc");
$message = "Someone coming from $HTTP_REFERER tried to reach some $SCRIPT_NAME, I don't know what they were thinking...";
mail("Leong_Yew@provider.com", "warning - fumbling visitor tripping over", "$message");
Enjoy!
Luciano ES
Santos, SP - Brasil