PEAR Articles

  Home arrow PEAR Articles arrow Page 2 - User Authentication for a PEAR CMS
PEAR ARTICLES

User Authentication for a PEAR CMS
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-10-15

    Table of Contents:
  • User Authentication for a PEAR CMS
  • Code Explained
  • String or Numeric
  • Granting Access to the CMS

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    User Authentication for a PEAR CMS - Code Explained


    (Page 2 of 4 )

    The code starts by defining some variables and then checking to see if the form has been submitted:

    <?php

    ob_start();

    session_start();

    $err=false;

    $error="";

    //check if form is submitted

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

    This line is responsible for checking if the form has been submitted:

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

     If the "$_POST['key']" global variable has been posted, it means that the form has been submitted. The "$_POST['key']" variable comes from a hidden form field, which we will discuss when looking at the HTML form that collects user input.

    If the form has indeed been submitted, the next step is to make sure that the submitted information is security checked. This step is very important, since most attacks against login scripts are carried out here. So we cannot afford to be lax about security at this juncture.

    Because there is information that we require, it is logical to make sure that the user has submitted that information. We go about checking for this information by using the empty() and is_numeric functions of PHP. First we check to see if the fields are empty. If they are empty, we set a Boolean variable to true:

    //make sure fields are not empty

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

    $err=true;

    $error="Please enter a username.<br>";

    }

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

    $err=true;

    $error .="Please enter a password.<br>";


    }

    More PEAR Articles Articles
    More By David Web

    blog comments powered by Disqus

    PEAR ARTICLES ARTICLES

    - Installing PEAR
    - PEAR: an Introduction
    - Managing robots.txt using PHP: Generating Dy...
    - Deleting Authors from a PEAR Content Managem...
    - PEAR CMS: Index and Delete Scripts
    - Listing Articles for a PEAR Content Manageme...
    - Building an Authors Page for a PEAR CMS
    - Building the View Details Page in a PEAR CMS
    - Creating the Main Pages of a PEAR CMS
    - Completing the Login Script for a PEAR CMS
    - User Authentication for a PEAR CMS
    - A PEAR CMS: Examining the Code
    - Building a Content Management System with PE...
    - Installing a PEAR Package
    - My PEAR: The Beginning


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap