PHP
  Home arrow PHP arrow Page 3 - User Management Explained: Overview
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 Management Explained: Overview
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 7
    2008-11-17


    Table of Contents:
  • User Management Explained: Overview
  • Form Explained
  • Script Explained
  • Password Encryption Methods

  • 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 Management Explained: Overview - Script Explained
    ( Page 3 of 4 )


    To start with, the script lists the number of steps that you need to take when working with form data. The first step is of course to validate the form data. This includes:

    • Checking if the name field is filled in.

    • Checking if it is the correct length.

    • Checking if it is valid, i.e it contains only letters.

    We can do this because we know what type of data we expect our application to be processing. Also we have put in some restrictions on the length that the name should be; in addition, we check to see if the value contains the right type of data. All of this is designed to ensure that any malicious user has a difficult time trying to carry out an attack.

    //validate data

    //1. Check if the name field is filled in:

    //2. Check if it is the correct length

    //3.Check if it is valid i.e it contains only letters


    The code than checks to see if the form has been submitted:


    if(isset($_POST['Submit'])){

    Once the form has been submitted, the first checks are carried out. This includes checking to see if the values are empty. This is achieved by using the very useful empty() function:

    $err=FALSE;

    $error="<ul>";


    if(empty($_POST['name'])){

    $err=true;

    $error .="<li>Please enter a name.</li>";

    }

    Then we check to see if the length of the name is eight characters long:

    if((strlen($_POST['name']))< 8){

    $err=true;

    $error .="<li>Please enter a valid name.</li>";

    }


    The last check is to make sure that the value actually contains only letters. We use regular expressions (the eregi() function) to check:


    if(!eregi('^[[:alpha:].'-]{2,8}$',$_POST['name'])){

    $err=TRUE;

    $error="<li>The name should only contain letters.</li>";

    }


    The age of the user is put through almost the same checks. Since we are dealing with a number, one of the checks includes testing the value to see if it is actually numeric. The is_numeric() function is used for this purpose:


    if(empty($_POST['age'])){

    $err=true;

    $error .="<li>Please enter a age.</li>";

    }


    if(!is_numeric($_POST['age'])){

    $err=true;

    $error .="<li>The age that you entered is not a number. Please check and try again</li></ul>";

    }

     



     
     
    >>> 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 4 Hosted by Hostway
    Stay green...Green IT