Home arrow PHP arrow Page 6 - Cracking The Vault (part 2)

Oops! - PHP

The first part of this article discussed the basic design andarchitecture for an intranet document management system. In this concludingpart, get to the good stuff with a discussion of the "check in" and "checkout" process, and add a simple search engine to the system.

  1. Cracking The Vault (part 2)
  2. Checking It Out
  3. Room With A View
  4. All Revved Up
  5. Looking For Something?
  6. Oops!
  7. Endgame
By: Vikram Vaswani, (c) Melonfire
Rating: starstarstarstarstar / 2
May 16, 2001

print this article


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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- 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: