PHP
  Home arrow PHP arrow Page 10 - User Authentication With Apache And PH...
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 
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

User Authentication With Apache And PHP
By: The Disenchanted Developer, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 53
    2002-03-13

    Table of Contents:
  • User Authentication With Apache And PHP
  • Back To Basics
  • The Right Creds
  • Hidden Costs
  • Logging In
  • Rank And File
  • Heavy Iron
  • Sock It To Me, Baby!
  • Time To Live
  • A Stitch In Time
  • Closing Time

  • 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


    User Authentication With Apache And PHP - A Stitch In Time


    (Page 10 of 11 )

    Assuming an authentication or session test fails, you've seen that the script "error.php" is invoked, and passed a cryptic error code via the $e variable. This "error.php" script is a generic error-handling script that produces an appropriate error message depending on the code passed to it. Take a look:

    <? // error.php - destroys session and returns to login form ?> <html> <head> <basefont face="Verdana"> </head> <body> <? // check the error code and generate an appropriate error message switch ($e) { case -1: $message = "No such user."; break; case 0: $message = "Invalid username and/or password."; break; case 2: $message = "Unauthorized access."; break; default: $message = "An unspecified error occurred."; break; } ?> <center> <? echo $message; ?> <br> Please <a href="index.php">log in</a> again. </center> </body> </html>
    Very simple - check the error code, print an appropriate message to let the user know what happened.

    Obviously, this script does not have any session checks at the top. Adding a session check to an error handler which includes code to trap the error of a user failing a session check would be reminiscent of that chicken-and-egg situation we all know and love.

    More PHP Articles
    More By The Disenchanted Developer, (c) Melonfire


     

       

    PHP ARTICLES

    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter
    - Building Your Own System Tray Application Us...
    - Structuring Your Projects for Web Applicatio...
    - Inserting, Updating and Deleting Database Ro...
    - Building Your Own Desktop Notepad Applicatio...
    - Web Application Security Overview
    - Working with the Active Record Class in Code...
    - Generate PDF Documents with PHP on the Windo...
    - Sending Email with PHP Networking
    - Performing Strict Validation with the Code I...
    - The preg_replace_callback() function in PHP
    - PHP Networking
    - Validating Web Forms with the Code Igniter P...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT