I am Asif Khalyani. I am software Engineer. PHP and ajax free script download site phpasks. User can download free php script.
This degradable form validation demo verifies the form at the server side on the classic form submit, and also implements AJAX validation while the user navigates through the form.
Degradable AJAX Form Validation
Doing a final server-side validation when the form is submitted is always a must. If someone disables JavaScript in the browser settings, AJAX validation on the client side won't work, exposing sensitive data, and thereby allowing an evil-intended visitor to harm important data back on the server (for example, through SQL injection). Always validate user input on the server!
This form validation application validates a registration form, using both AJAX validation (client side) and typical server-side validation:
* AJAX-style (on the client), when each form field loses focus (onblur). The field's value is sent to the server, which validates the data and returns a result (0 for failure, 1 for success). If validation fails, an error message will unobtrusively show up and notify the user about the failed validation.
* PHP-style (on the server), when the entire form is submitted. This is the usual validation you would do on the server, by checking user input against certain rules. If no errors are found and the input data is valid, the browser is redirected to a success page. If validation fails, however, the user is sent back to the form page with the invalid fields highlighted.
Both AJAX validation and PHP validation check the entered data against these rules:
* Username must not already exist in the database
* Name field cannot be empty
* A gender must be selected
* Email address must be written in a valid email format, such as xyz@domain.com
* Phone number must be written in standard US form: +xx xxxxxxxxx
Thread-Safe AJAX
A piece of code is thread-safe if it functions correctly during simultaneous execution by multiple threads. In this exercise, we need to make an asynchronous request to the server to validate the entered data every time the user leaves an input box or changes a selection.
The hidden danger behind this technique is only revealed if the user moves very quickly through the input fields, or the server connection is slow; in these cases, the web application would attempt to make new server requests through an XMLHttpRequest object that is still busy waiting for the response to a previous request (this would generate an error and the application would stop functioning properly).
Depending on the circumstances at hand, the ideal solution to this problem may be:
* Create a new XMLHttpRequest instance for every message you need to send to the server. This method is easy to implement, but it can degrade server's performance if multiple requests are sent at the same time, and it doesn't guarantee for the order in which you receive the responses.
* Record the message in a queue and send it later when the XMLHttpRequest object is able to make new requests. The requests are made in the expected order. Using a queue is particularly important in applications where the order of the messages is important.
* Schedule to automatically retry making the request after a specified amount of time. This method is similar to the one with the queue in that you don't make more than one server request at a time, but it doesn't guarantee for either the order in which the requests are made, or for the order in which the responses are received.
* Ignore the message.
In this form validation exercise, we use a message queue. When the user leaves an input element, a message to validate its value is added to the queue. When the XMLHttpRequest object is clear to make a new request, it takes the first message from the queue.
The queue is a First-In, First-Out (FIFO) structure, which guarantees that the messages are sent in the proper order. To get a feeling about how this works, go to the demo page, and press tab quickly multiple times, and then wait to see how the validation responses show up one by one.
The complete AJAX and PHP tutorial features even more AJAX web development examples.
Downlaod code
PHP and Ajax submit form
- Related Videos
- Related Articles
- Ask / Related Q&A
- Upload Image Without Refresh Page - Asynchronous Image File Upload Without Ajax
- Ajax Form Validation and Thread-safe Ajax
- Crop Image File Size, Width & Height Using Php Script
- Adding an Ajax Web Photo Gallery to Your Website for Amateurs. (based on My Own Experience)
- Learn How to Store and Share Your Files by using Ajax
- Save time with ScriptArtist PHP and AJAX code generator!
- Coppermine—A Popular Multi-lingual Image Gallery
- Social Network Website For Sell




Integrating facebook in cakephp
By: Digisha Modi | 30/12/2009FaceBook Application is the powerful tool of marketing or to connect people for all type of business. Now it's easier to find social applications on Facebook, on your phone, and on external websites. The new "Featured by Facebook" section highlights Facebook's favorites. Since 2007 the kind of concept FaceBook has come up with become a unique challenger to established payers. The benefit of FaceBook application is any one can post their own application with out any cost.
Outsourcing of iPhone Application Development Offers Profits for Developers as Well as Users
By: Arun Kumar | 30/12/2009Being a 3G phone, it offers users the advantage of thrilling web access which helps them being on top of all online activities even on the move. Also, there are several additional applications available for download for the device. Thanks to the efforts of the outsource iPhone application development firms which have helped iPhone users get more with their devices using the apps developed by their expert developers.
Pass4side 000-135 practice test
By: Adela1987 | 30/12/2009Pass4side 000-135 Details: Pass4side is your source for the IT Exam 000-135 exam. With our 000-135 Exam Resources, you can be rest assured that you will Pass your 000-135 Exam on Your First Try. Our Exams are written and formatted by Top senior IT Professionals working in today is prospering companies and data centers. All of our practice exams including the IBM 000-135 exam guarantee you success on your First Try. 000-135 is a challenging exam,with our 000-135 study guide,you can feel safe wit
Open Source Development
By: Digisha Modi | 30/12/2009Open Source Software are free applications released under special licensing terms where the core coding is viewable and able to be edited to suit the needs of the user. Open Source applications cover a myriad of uses - from entertainment to enterprise ecommerce. Open source software like Joomla, magento and osCommerce are very popular and widely used. They are content management system and it maintains track of every piece of content including music, videos, text, widgets, images and documents.
Cakephp PhpBB Integration
By: Digisha Modi | 29/12/2009PhpBB Forum is a popular bulletin board script written in the server side scripting language PHP. Installable on most web servers, it is free open source Framework available under the GNU public license. The software allows website and forum administrators to set up unlimited number of forums and categories. It is also possible to create users, moderators and user groups with varying degrees of permissions.
Cakephp Amazon API Integration
By: Digisha Modi | 29/12/2009The Amazon Web Service lets your cakephp web applications make queries to the huge database of products at Amazon and extract as much information as you need. The information you get in your application is exactly the same that is available on the Amazon website at that instant. The Amazon Web Service returns data in real-time, and updates automatically.
Easy way to set up global API hooks
By: Apriorit Inc. | 28/12/2009This article describes an easy way to set up system-wide global API hooks. It uses AppInit_DLLs registry key for DLL injection and Mhook library for API hooking. To illustrate this technique we will show how to easily hide calc.exe from the list of running processes.
Ruby Development Philosophy Today
By: Inessa Bokhan | 28/12/2009After taking a decision to launch a Web 2.0 project, independent software vendors (ISVs) can get overwhelmed with hundreds of thoughts, concerning the future project and its performance. However, the idea of choosing between various Web technologies available at the moment may bring in some confusion. What would be more beneficial, Adobe Flex, Silverlight, JavaFX, Ruby development, or whatever?
Easy Ajax Inline Text Edit 2.0
By: Asif Khalyani | 09/09/2008 | ProgrammingA small piece of javascript reads al SPAN tags, checks if it has class="editText" and a id=. If that is true, it adds a onclick function. That onclick function will create a textfield or input (depending on the size of the editable text). Someone has the ability to edit the field. When the text field is blurred, it will read the contents, and starts a XMLHttpRequest and ‘sends’ the content + fieldname + any set vars to an update file.
Ajax Rating Script - Php & Mysql
By: Asif Khalyani | 09/09/2008 | ProgrammingFrequent visitors of ajax enabled websites, like ajaxian, have all witnessed them already: ajax rating widgets.
Crop Image File Size, Width & Height Using Php Script
By: Asif Khalyani | 03/07/2008 | ProgrammingCropping and resizing your images for the Web is a common technique for creating smaller thumbnail images that download quickly.
Ajax Form Validation and Thread-safe Ajax
By: Asif Khalyani | 03/07/2008 | ProgrammingThis is the PHP and AJAX form validation application you can create AJAX and PHP: Building Responsive Web Applications.