PHP
  Home arrow PHP arrow Page 6 - Cracking The Vault (part 2)
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Cracking The Vault (part 2)
By: Vikram Vaswani, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 2
    2001-05-16

    Table of Contents:
  • Cracking The Vault (part 2)
  • Checking It Out
  • Room With A View
  • All Revved Up
  • Looking For Something?
  • Oops!
  • Endgame

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Cracking The Vault (part 2) - Oops!


    (Page 6 of 7 )

    The last script - and the simplest - 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 - displays error messages based on error code $ec // includes include("config.php"); switch ($ec) { // login failure case 0: $message = "There was an error logging you in. <a href=start.html>Please try again.</a>"; break; // session problem case 1: $message = "Please <a href=start.html>log in</a> again."; break; // malformed variable/failed query case 2: $message = "There was an error performing the requested action. Please <a href=start.html>log in</a> again."; break; // file not uploaded case 11: $message = "Please upload a valid document."; break; // rights not assigned case 12: $message = "You must assign view/modify rights to at least one user."; break; // illegal file type case 13: $message = "That file type is not currently supported.<p>Please upload a document conforming to any of the following file types:<br><ul align=left>"; foreach($allowedFileTypes as $this) { $message .= "<li>$this"; } $message .= "</ul>"; break; default: $message = "There was an error performing the requested action. Please <a href=start.html>log in</a> again."; break; } ?> <html> <head> <basefont face="Verdana"> </head> <body bgcolor="White"> <p> <? echo $message; ?> </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.

    This article copyright Melonfire 2001. All rights reserved.

    More PHP Articles
    More By Vikram Vaswani, (c) Melonfire


     

       

    PHP ARTICLES

    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview
    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application
    - Sending MIME Email with PHP
    - Handling Files for a Project Management Appl...
    - Viewing and Editing Tasks for a Project Mana...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway