PHP
  Home arrow PHP arrow Page 4 - User Authentication for a Project Management Application
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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 for a Project Management Application
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 1
    2008-08-18


    Table of Contents:
  • User Authentication for a Project Management Application
  • User Information
  • The Script
  • Checking the User and Email

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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 for a Project Management Application - Checking the User and Email
    ( Page 4 of 4 )

    After running the initial checks on the form values, the code gets to the most important bit of the program, which is to see if the user and email address actually exists in the database. Remember, anyone can enter any email address with the correct username and try to get the password sent to an email address that is not connected to the username. Therefore, in this program, we will guard against this tactic by checking (in the database) to see if the username and email address entered are connected:

    if(!$err){

    $cleanuname = mysql_escape_string($_POST['uname']);

    $cleanemail = mysql_escape_string($_POST['email']);

    $unamecheck = "SELECT email,name,sname FROM users WHERE username='".$cleanuname."' and email = '".$cleanemail."'";

    $result=mysql_query($unamecheck);

    $num=mysql_num_rows($result);

    if($num > 0){

    $row = mysql_fetch_assoc($result);

    $thepass = $row['upass'];

    $theName = $row['name'];

    Once we’ve established that the password actually belongs to the person requesting it, we then proceed to create a email message, and send the password to the email address provided.

    //build email headers

    //this text will appear in the subject line of the email

    $subject = "Project Management - Password Recovery";

    //this is the recipient of the email

    $to = $cleanemail;

    //sender name

    $from_name = "Project Management Application";

    //sender address

    $from_email = "website@mywebsite.com";

    $headers = "From: " . $from_name . " <" . $from_email . ">";

    //build message

    $msg = "<html>

    <head>

    <title>Project Management</title>

    <link rel='stylesheet' type='text/css' href='http://www.yourwebsitelocationhere.com/loginstyle.css'>

    </head>

    <body>

    <table width='100%' border='0' cellspacing='0' cellpadding='0'>

    <tr>

    <td><p>Dear <b>".$theName."</b></p>

    Below is the password you requested:<br />

    <br />

    <b>Password:</b> ".$thepass.";


    </td>

    </tr>

    </table>";

    $msg .= "</body>

    </html>";


    mail($to, $subject, $msg, $headers);

    }else{

    If the information that the user provides does not match up, we set the appropriate error message and display it in the password form.

    $err=true;

    $errmsg .="The information you entered is incorrect or does not exists. ";


    }

    }

    }//end submit

    Like the other forms, the password form allows a space on the form to display the error message. 

    <?php if(isset($errmsg)){?>

    <tr>

    <td colspan="2" class="errmsg"><?php echo $errmsg; ?></td>

    </tr>

    <tr>

    <td colspan="2">&nbsp;</td>

    </tr>

    <tr>

    <?php

    }

    ?>

    Conclusion

    That is all there is to the user authentication system for the project management application. I am sure there are some things that can be improved, and no doubt some of you will do so. We’ve covered a lot of ground in the last couple of articles dealing with user authentication and I hope that it will give some of you more ideas on how to make your login scripts more secure.



     
     
    >>> More PHP Articles          >>> More By David Web
     

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT