Home > Article > Backend Development > Create a 404 error page and send it to the administrator
";
echo "Oso Network Administrator reminds you that the page you requested, $docroot$REQUEST_URI, doesn't exist";
echo " on this server.
";
The above introduces how to create a 404 error page and send a letter to the administrator, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.
echo "The error message has been sent to the Oso network administrator.";
}
Return;
}
#EMAIL processing function
function send_email()
{
# Request access to the global variables we need
global $REQUEST_URI, $HTTP_REFERER, $emailaddress, $REMOTE_ADDR, $docroot;
# Customize the messages sent, such as time and location, etc.
$today = getdate();
$month = $today[mon];
$mday = $today[mday];
$year = $today[year];
$hours = $today[hours];
$minutes = $today[minutes];
$errortime = "$month/$mday/$year at $hours:$minutes";
#Create the body of the email message
$message .= "404 Error ReportnnA 404 error was encountered by $REMOTE_ADDR";
$message .= " on $errortime.nn";
$message .= "The URI which generated the error is: n$docroot$REQUEST_URInn";
$message .= "The referring page was:n$HTTP_REFERERnn";
# Send the mail message. This assumes mail() will work on your system!
Mail("$emailaddress", "404 Error Report", $message, "From: $emailaddress"); //Okay, send the letter
Return;
}
# The following are based on the setting of the variable $reportlevel to send or not.
print_details();
# See whether or not we should send an email report. If so, do it.
if ($reportlevel != 0)
if ($reportlevel == 1) {
If (eregi($domain,$HTTP_REFERER))
send_email(); }
else
send_email();
# All done!
exit;
?>