GIDForums

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum > PHP Code Library
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 19-Aug-2003, 20:10
BobbyDouglas's Avatar
BobbyDouglas BobbyDouglas is offline
Regular Member
 
Join Date: Aug 2003
Posts: 789
BobbyDouglas has a spectacular aura aboutBobbyDouglas has a spectacular aura about

[script] E-mail webmaster error page


There are two parts to this script. The first part, functions.inc.php is used to e-mail the error code to a recipiant of your choice. The second part you must place on the error page itself, above all the HTML/CODE that is already their.

***********PART 1************

PHP Code:

<?php

/**

  * @domain:    DESILVA.BIZ      
  * @file:      FUNCTIONS.INC.PHP      
  * @author:    J de Silva
  * @website:   www.desilva.biz
  * @email:     scripts[AT]desilva[DOT]biz
  * @copyright: Gen.I designs
  * @date:      August 19th, 2003
  * @version:   n/a
  * @about :    The 'engine' behind a simple PHP error page. 
                        This script will send an e-mail to the address 
                        specified including a subject with the error 
                        code, and a breif message that includes the 
                        error code, the date, the IP, and the page 
                        that was not found.

  *              

/*===================================*/

function send_error_email( $error_code='Undefined' )

{  
  // set the TO: email address
  // make sure to change [email]johndoe@domain.com[/email] to the
  // address you wish the e-mail be sent to
  $to = 'johndoe@domain.com';
  
  // set the SUBJECT: e-mail
  $subject = "An error has occured - type: $error_code";
  
  // set the MESSAGE: e-mail    
  $message = "The following error has occured:\r\n"

            ."--------------------------------\r\n\r\n"
            ."  Type: $error_code\r\n"
            ."  Page:  {$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}
\r\n"
            ."  Time: ".date('d/m/Y H:i:s')."\r\n"
            ."  From IP: {$_SERVER['REMOTE_ADDR']}\r\n\r\n"
            ."Regards,\r\n"
            ."Your hard-working web server.";


  $headers = "From: webserver@{$_SERVER['SERVER_NAME']}\n"
            ."Reply-To: webserver@{$_SERVER['SERVER_NAME']}\n"
            ."X-Mailer: PHP/".phpversion();


  // send the email
  mail( $to, $subject, $message, $headers );

}

?>




***********PART 2************
PHP Code:

<?php

/**

  * @domain:    DESILVA.BIZ      
  * @file:      404.PHP      
  * @author:    J de Silva
  * @website:   www.desilva.biz
  * @email:     scripts[AT]desilva[DOT]biz
  * @copyright: Gen.I designs
  * @date:      August 19th, 2003
  * @version:   n/a
  * @about :    The script that sends the information to the 
                        functions file which sends the e-mail. To 
                        change the error code, just change the 404 
                        from send_error_email( '404' ) to whatever 
                        error you want. Place this file above the 
                        404.php page, then display the rest of your 
                        HTML below. Last thing you must enter is the
                        location of the functions.inc.php page. Just
                        as an example, we have said the page is
                        located at /errorpgs/functions.inc.php.
       
  *              

/*===================================*/

   // FILENAME: 404.PHP

   // include the filenamed : functions.inc.php...
   // assuming that both files are in the same directory
   include_once( $_SERVER['DOCUMENT_ROOT'].'/errorpgs/functions.inc.php' );


   // Everytime someone reaches this page, i.e. 404.php, an email gets sent out
   send_error_email( '404' );

?>



For help with this script, please use this thread: http://desilva.biz/forum/viewtopic984.php
 

Recent GIDBlogNon-US citizens serving in the military by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[script] Handling Error 404 JdS PHP Code Library 0 19-Nov-2003 08:22
Reliable Hosting $2-$8/month: PHP, MySQL, FrontPage, CGI, SSH, FTP, POP3, Web Mail fcolor Web Hosting Advertisements & Offers 0 04-Nov-2003 06:03
600MB Space, 20GB Banwidth, PHP, MySQL, CGI, SSH, FrontPage, FTP, POP3, Web Mail fcolor Web Hosting Advertisements & Offers 0 08-Aug-2003 10:11
E Mail Forwarding nikkotash Computer Software Forum - Windows 3 30-Jun-2003 03:20

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 13:34.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.