PEAR Articles

  Home arrow PEAR Articles arrow Page 2 - 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

    TOOLS YOU CAN USE

    advertisement

    Completing the Login Script for a PEAR CMS - JavaScript


    (Page 2 of 4 )

    The JavaScript code is responsible for ensuring that the username and password fields are filled in when the user submits the form. It is sometimes better to have these kinds of checks on the client side rather than on the server side, where the form data is send to the server for processing and then returned to the browser to show the user the results.

    The JavaScript checks the form data locally before it goes to the server. The JavaScript code declares and implements one function called checkform(). This function takes one argument, which is the name of the form.

    <script language="javascript" type="text/javascript">

    function checkform(pform1){

    The first part of the function checks to see if the username field has been filled in. If not, it alerts the user of that fact and sets the focus back on that field.

    if(pform1.uname.value==""){

    alert("Please enter a username")

    pform1.uname.focus()

    return false

    }



    The second part of the function checks to see if the password field is filled in, otherwise it shows an alert:

    if(pform1.upass.value==""){

    alert("Please enter a password")

    pform1.pw.focus()

    return false

    }



    The final part of the function checks to see if both the username and password has been filled in; again, it shows the user a error dialog if the information is not filled in. 

    if(pform1.pw.value=="" && pform1.uname.value==""){

    alert("Please make sure that you have entered your username and password")

    return false

    }


    return true

    }


    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 6 - Follow our Sitemap