PEAR Articles

  Home arrow PEAR Articles arrow Completing the Login Script for a PEAR...
PEAR ARTICLES

Completing the Login Script for a PEAR CMS
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-10-22

    Table of Contents:
  • Completing the Login Script for a PEAR CMS
  • JavaScript
  • The logout script
  • The CMS

  •  
     

    SEARCH CODEWALKERS

    Completing the Login Script for a PEAR CMS


    (Page 1 of 4 )

    Welcome to the sixth part of a twelve-part series on building a content management system with PEAR. In this article we will continue to look at the code that makes up the login script as well as the HTML form that is used to collect the login information. We will also discuss the code that makes up the logout script.

     

    The login form


    The login form is very simple in its design and purpose. Its purpose is to collect the required information from the user. It will take the user's password and username.

    The form has three main fields: Username, which of course takes the user's username; Password, which takes the user's password; and Key. Key is a hidden field that is used to test whether the form has been submitted. It is used because sometimes users press the return key instead of pressing the submit button on the form. If you then use the submit button to test whether the form is submitted, it will not work, especially if the user presses the return key. This way both scenarios are considered. 

    Letís look at the HTML code that makes up the HTML form. The first part of the form sets up the page with the template and also includes some JavaScript code, which we will discuss shortly. We look at the body section that actually contains the form and its elements:


    <body>

    <table width="100%" border="0" class="bord">

    <tr class="header1">

    <td colspan="2"><div align="center">Content Management System </div></td>

    </tr>

    <tr>

    <td width="5%" valign="top"><!-- InstanceBeginEditable name="EditRegion4" --><!-- InstanceEndEditable --></td>

    <td width="95%" valign="top"><!-- InstanceBeginEditable name="EditRegion3" -->

    The section builds a table that hosts the form. Notice in the code below that the form tag includes an onSubmit() tag. This tag links the form to the JavaScript code that is located in the header section of the HTML document. 

    <form action="login.php" method="post" onSubmit="return checkform(this)">>

    <table width="100%" border="0">

    <tr>

    <td colspan="2"><?php if($error){

    echo $error;

    }?></td>

    </tr>

    Please examine the code above the PHP section. This is where the error message will be displayed when an error is detected while the form data is been filtered. The code below shows the username form element that is responsible for collecting the username of the person that wants to use the CMS.

    <tr>

    <td width="15%"><strong>Username</strong></td>

    <td width="85%"><label>

    <input name="uname" type="text" size="40" value="david"/>

    </label></td>

    </tr>

    The next two elements are the password and key fields, responsible for taking the user's password and test key, respectively:

    <tr>

    <td><strong>Password</strong></td>

    <td><label>

    <input name="upass" type="password" value="pass" size="40" />

    <input type="hidden" name="key" />

    </label></td>

    </tr>

    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

    Developer Shed Affiliates

     



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