PHP
  Home arrow PHP arrow Page 3 - Application Framework Components: Logi...
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 
Actuate Whitepapers 
Moblin 
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

Application Framework Components: Login/Logout
By: Chris Neeman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 8
    2007-09-04

    Table of Contents:
  • Application Framework Components: Login/Logout
  • Login Class Functions
  • Setting up the SQL Query
  • The Remaining Login Class Functions

  • 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

    Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!

    Application Framework Components: Login/Logout - Setting up the SQL Query


    (Page 3 of 4 )

    Once we are successfully connected to the database, we continue to set up the SQL query. The query checks for two things. First, it checks to see if the email address that the user passed exists in the database, and then it checks to see if that account is active. So even if the email address exists, but the account is inactive, the function would return a error:

    //see if the user password and email is in the table
    $query ="SELECT uid, upass,CONCAT(name,' ',sname) as
    name,access_level,depid FROM ".$this->dbtbl." WHERE email =
    '".$this->email."'";
    $query .="AND isActive = '1'";

    The query is then executed:

    $result =$dbcon->a_query($query);

    If the result of the query is false, the user was not found in the database, so we set the login status to false:

    //set the authorization status accordingly
    if(!$result){
     
    $this->loginstatus=FALSE;

    If the result of the query is true, then the user does have an active account in the database. We then continue to further authenticate the user by comparing the user-submitted password with the one retrieved from the database:

    }else {
     
    $row=$result->fetchrow();
     
    //compare user submitted password with the one from the database:
     
    if($this->password == $row->upass){

    If the two passwords are the same, then we assign the database-retrieved information to some of the global variables declared earlier:

      $this->userid=$row->uid;
      $this->uname = $row->name;
      $this->access =$row->access_level;
      $this->did =$row->depid;
      $this->em=$email;
      //$this->email=$row->email;
      $this->loginstatus=TRUE;
    }

    If the passwords don't match, then the appropriate error is shown and the database connect is terminated:

        else{
         
    $this->err=$dbcon->showerror();
         
    $this->loginstatus=FALSE;
        }//password check
      }
      $dbcon->disconnect();
      return $this->loginstatus;
    }

    More PHP Articles
    More By Chris Neeman


     

       

    PHP ARTICLES

    - 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...
    - More on Private Methods with PHP 5 Member Vi...
    - Adding Tasks to a Project Management Applica...
    - Utilizing Private Methods with PHP 5 and Mem...
    - Making Changes in a Project Management Appli...
    - Defining Public and Protected Methods with M...
    - HTML for a Project Management Application
    - Using Subclasses and Accessors with Member V...
    - Implementing Internet Protocols with PHP
    - Project Management: The Application
    - Working with Private Properties to Protect P...




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