AJAX
  Home arrow AJAX arrow Page 3 - Protecting Web Forms with AJAX
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? 
Google.com  
AJAX

Protecting Web Forms with AJAX
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 7
    2009-03-18


    Table of Contents:
  • Protecting Web Forms with AJAX
  • Developing a verification code mechanism
  • Generating verification codes with Ajax
  • Generating verification codes on the web server

  • 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


    Protecting Web Forms with AJAX - Generating verification codes with Ajax
    ( Page 3 of 4 )

    In the section that you just read, I coded a simple HTML form for demonstrating how an Ajax-driven program can make it a bit safer against attacks and fake submissions. In this case, I’m going to develop a random code generator that will be coupled to the form, so each time a users tries to submit it, they will be asked to enter this checking code. So far, nothing unexpected, right?

    However -- and here’s where things will get really interesting -- the verification code will be generated on the fly via an Ajax-based HTTP request. Therefore, to perform this task, I’m going to use the assistance of the Ajax module bundled with the jQuery library, in this way saving time and effort.

    Basically, the Ajax application that will be charged with generating verification codes dynamically for the previous HTML form looks like this:

    <script language="javascript" src="jquery.js"></script>

    <script language="javascript">

    $(document).ready(function(){

    // get verification code with Ajax

    $.get('get_checkingcode.php',{data:'getting code'},function(checkingcode){$('#codebox').html(checkingcode);});

    });

    </script>


    Even if you’re not familiar with the API of the jQuery library, it’s pretty easy to understand how the above script works. In simple terms, it will request with Ajax a PHP file called “get_checkingcode.php,” which will be responsible for generating a random verification code.

    Then, this string will be sent back to the client, where it will be displayed within the HTML form before the form is submitted. You can see how this implements a simple mechanism that will protect the form against automated submissions. Of course, this isn’t a bullet-proof approach, and certainly can be improved. But it can be quite useful for making web forms more secure, without having to deal directly with a server-side graphic library.

    Now that you hopefully grasped how verification codes will be generated via Ajax-based HTTP requests, it’s time to build the PHP file that actually sends this random string to the client.

    The full details of how this PHP file will be created will be discussed in the course of the following section. Thus, click on the link below and read the next few lines.



     
     
    >>> More AJAX Articles          >>> More By Alejandro Gervasio
     

       

    AJAX ARTICLES

    - PHP AJAX Form Validation
    - Completing a User-Defined CSS Website with P...
    - Create a User-Defined CSS Website with PHP
    - Build A Better Twitter Chat Client Than Cham...
    - Using Division Equations to Make Web Forms S...
    - Using Integer Multiplication to Protect Web ...
    - Using Simple Checksums for Web Form Verifica...
    - Protecting Web Forms with AJAX
    - Using Prototip with AJAX
    - Using Prototip
    - Using the google.load() Method with Google`s...
    - How to Handle Ajax Errors
    - Uncompressing Source Files with Google`s AJA...
    - Using the jQuery Framework with Google`s Aja...
    - Using Google`s Ajax Libraries API




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek