Home arrow PHP arrow Page 7 - Building A PHP-Based Mail Client (part 3)

When Things Go Wrong... - PHP

This third (and final) segment of our case study discusses theprocess of sending MIME-encoded email, demonstrating how to compose,forward and reply to email through a Web browser. It also discusses, indetail, the process of constructing a MIME-encoded message withattachments, explains PHP's HTTP upload capabilities, and examines thestandard error handler used throughout this case study.

TABLE OF CONTENTS:
  1. Building A PHP-Based Mail Client (part 3)
  2. Composing Yourself
  3. Return To Sender
  4. Coming Forward
  5. Setting Boundaries
  6. Under Construction
  7. When Things Go Wrong...
  8. Game Over
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 8
January 23, 2002

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
The last script - an extremely simple one - is the error handler, "error.php". If you look at the source code, you'll notice many links to this script, each one passing it a cryptic error code via the $ec variable. Very simply, "error.php" intercepts the variable and converts it to a human-readable error message, which is then displayed to the user.

<? // error.php - error handler switch($ec) { // login failure case 1: $message = "An error occurred while logging you in. Please verify your account information and <a href=logout.php>log in again</a>."; break; // session authentication failure case 2: $message = "An error occurred while performing your request. Please <a href=logout.php>log in again</a>."; break; // POP3 connection problem case 3: $message = "A connection could not be opened to the mail server. Please verify your account information and <a href=logout.php>log in again</a>."; break; // missing variable case 4: $message = "An error occurred while performing your request. Please <a href=logout.php>log in again</a>."; break; // email addresses absent case 6: $message = "Your message could not be processed, as it contained no valid recipient addresses. Please <a href=compose.php>try again</a>."; break; // attachment problem case 7: $message = "An error occurred while uploading the message attachment. Please <a href=compose.php>try again</a>."; break; // email addresses invalid case 8: $message = "Your message could not be processed, as it contained one or more invalid email addresses. Please <a href=compose.php>try again</a>."; break; // everything else default: $message = "An unspecified error occurred while performing your request. Please <a href=logout.php>log in again</a>."; break; } ?> <html> <head> </head> <body bgcolor="White"> <? // page header ?> <font face="Verdana" size="-1"> <? echo $message; ?> </font> </body> </html>
Here's what it looks like.



Simple and elegant - not to mention flexible. Found a new error? No problem - assign it an error code and let "error.php" know.

 
 
>>> More PHP Articles          >>> More By icarus, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: