topical media & game development
basic-php-09-error-rev02.php / php
<?php
function email_admin(error_output,
full_time,
to = "Administrator <admin@yourdomain.com>";
body = "<html>";
body .= "<title>Apache Error</title>";
body .= "<body>";
full_date . "</b> " .
"at <b>" . body .= "Error received was a <b>" . body .= "The page that generated the error was: <b>" .
body .= "The generated error message was:" . body .= "</body>";
headers = "MIME-Version: 1.0\r\n";
headers .= "From: Apache Error <host@yourdomain.com>\r\n";
to, body, date = getdate();
date['weekday'] . ", " .
date['mday'] . ", " .
full_time = date['minutes'] . ":" .
date['year'];
_SERVER['QUERY_STRING'];
_SERVER['REQUEST_URI'];
switch (error_output = "<h1>\"Bad Request\" Error Page - " .
"(Error Code 400)</h1>";
error_output .= "<a href=\"mailto:sysadmin@localhost.com\">" .
"Contact</a> the system administrator";
error_no,
full_date,
request_page);
break;
case 401:
error_output .= "You have supplied the wrong information to " .
"access a secure area<br>";
error_output .= " if you feel this to be in error";
email_admin(error_output,
full_time,
error_output = "<h1>\"Forbidden Access\" Error Page - " .
"(Error Code 403)</h1>";
error_output .= "<a href=\"mailto:sysadmin@localhost.com\">" .
"Contact</a> the system administrator";
error_no,
full_date,
request_page);
break;
case 404:
error_output .= "The page you are looking for " .
"cannot be found<br>";
error_output .= " if you feel this to be in error";
email_admin(error_output,
full_time,
error_output = "<h1>\"Internal Server Error\" Error Page - " .
"(Error Code 500)</h1>";
error_output .= "<a href=\"mailto:sysadmin@localhost.com\">" .
"Contact</a> the system administrator";
error_no,
full_date,
request_page);
break;
default:
error_output .= "This is the custom error Page<br>";
error_output;
?>
</body>
</html>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.