PHP
  Home arrow PHP arrow Page 3 - Using the PHP Crypt Function
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 
Mobile Linux 
App Generation ROI 
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

Using the PHP Crypt Function
By: Chris Root
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 32
    2005-01-17

    Table of Contents:
  • Using the PHP Crypt Function
  • A Practical Example
  • Login
  • A Few Words About Storage and Security

  • 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


    Using the PHP Crypt Function - Login


    (Page 3 of 4 )

    Login would use a similar form, but now we are comparing a stored encrypted password with one entered by the user. The usual validating code can be used on the form input. Once this is done we make our database or file connections and retrieve the needed information. We then make our comparisons, and when we receive a successful match, start a new session for our logged in user and redirect them to the admin interface page. If there is no match we simply prompt the user to try again.

    You could also set up a way to track the number of times a user attempted to log in within a certain period of time if you wished. Options to reset passwords and have passwords emailed to the user are also good add-ons. Of course keep in mind that wherever you store an unencrypted password, it had better be secure. If the information you are protecting is something like credit card information, it's even more important.

    //the array $row is from the database that holds our information.
    if(crypt($pwrd,$row[pword]) == $row[pword])
    {
    session_start();//start the new session
    $sesid = session_id();//get the session id
    $_SESSION[logged] = TRUE;//set a session id to check if this user is logged in
    header("location: chooser.php?id=$sesid");//redirect the user to the admin interface page
    break;
    }
    else//whoops no match but be nice and let them try again.
    {
    echo "<html><head></head>
    <body><h1>Sorry No Passord matches.
    </h1><a href = \"admin_login.html\">Try Again?</a></body></html>";
    break;
    }

    More PHP Articles
    More By Chris Root


       · However, md5() in not encryption, its hashing; just though I would point that...
       · Yes actually you are correct. Not a lot of people know the difference but it is an...
       · Using a non standard hashing (or crypto) function is a good way to get in troubles...
       · Actually Crypt is entirely based on standards. It uses standard ciphers available...
       · First thing that came to my mind is implementing this function with passwords. Since...
       · The way I would manage this is for a non encrypted version to be stored in a...
       · can you explain hashing? new to this, and thought md5 was encrypting the password? ...
       · Can anyone tell the difference between hashing and crypting?and which one is...
       · The best explanation I have seen for the difference is...
       · This is the way it SHOULD be. When a user loses his password, he gets sent a new...
       · With appreciation to the author, there are serious weaknesses here. 1) Crypt()...
       · Has nobody spotted the obvious flaw here? You are still sending the password in...
     

       

    PHP ARTICLES

    - Using Aliases and the Autoload Function with...
    - Authentication Scripts for a User Management...
    - Utilizing the Use Keyword for Namespaces in ...
    - Building a User Management Application
    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Sub Classing Exceptions in PHP 5
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




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