>All Tutorials 
Ajax and .NET Ajax and .NET RSS XML
Ajax and ColdFusion Ajax and ColdFusion RSS XML
Ajax and Java Ajax and Java RSS XML
Ajax and PHP Ajax and PHP RSS XML
Ajax and SOA Ajax and SOA RSS XML
Ajax Goodies Ajax Goodies RSS XML
Ajax Tool Ajax Tool RSS XML
Facebook MockAjax Facebook MockAjax RSS XML
Google Web Toolkit Google Web Toolkit RSS XML
JavaScript Framework JavaScript Framework RSS XML
Ruby on Rails Ruby on Rails RSS XML
Technique Introduction Technique Introduction RSS XML
Without XMLHttpRequest Without XMLHttpRequest RSS XML
Yahoo! UI Yahoo! UI RSS XML

Form validation with AJAX/PHP/MySQL - function required field var fields error place id

 
Registered tutorials: 501
Registered Users: 33126



Rating: 3.86 out of 98 votes cast


  
Category: Ajax and PHP

Tags Map

action actions add address ajax array articles basic border browser button called calling change check class code color connect data database define die dieproblem display div divtd echo email emailfield empty equal error errors field fields form forvar function functions hcould highlight http id ifaction ifnum ifproblemarraylength loop message mysql mysqlqueryquery negative num number onblur onfocus option output page passed password php phpfreaksusers pipe place pos problemarray query remove required result return ro select set simple space specific start string style submit table td tdinput test testfield testoption text tr trim trimstring tutorial txtfield type understanding update url user userfield username validation var variable variables width

Keyword Cloud Navigation Map

Form validation with AJAX/PHP/MySQL

Digg this   Post to del.icio.us

Abstract: This tutorial will do a simple check against the database and returning an error if the field is already present, if not, no error

Here is a simple, quick way to validate required form fields using AJAX, PHP and MySQL. What we’re going to do is display an error message to the right of the required field, and if there are errors, restrict the submit button. And if a user were to skip a required field, or leave it blank, we’ll highlight it along with removing the submit button.

I feel this is useful because it validates on the fly using PHP methods that we may already have in place – there is no need to learn the “Javascript way” to do something that you’ve been doing for a while. I make a few assumptions in this tutorial. The first is that you have a basic understanding of PHP and how to connect to a MySQL database and retrieve records. Along with that, for this tutorial, you’ll need a table setup with usernames and email addresses stored in it; my table will be called “users.” The second is that you have some understanding of how AJAX works. Third is that you have an understanding of CSS and how to define classes and id’s. You could figure these things about by going through this tutorial, but it would be a lot easier on you if you do understand what I laid out.

rnrnLets Get Started

We’re going to start by making the form and adding names, id’s and actions to the fields. In my example, there will be six form fields, four of them being required (three being regular fields, one being a dropdown box). And next to each required field, we’ll have an empty space that will be used to display a specific error message returned through AJAX. A simple check will be carried out against the database and an error message will be displayed if the field is already present. We also have an empty div to display either the error message or submit button for the form. You can add your fancy data checking later.

*In this example I will only check against the first two FROM fields; username and email address.

The field id is the most important element in this script. So we’ll be using a simple naming convention to keep the code clean and hopefully simple; *field* name=”xxx” id=”xxxfield” and the error container will have an id of xxxfield_container.

Read Full Tutorial...



Reviews:

Rate and Review This Site

2007-12-07 02:14:15
good site for begginer with ajax




Statistic Information About this Resource:


Total Hits: 21820
Unique Hits: 17189


  Daily Weekly Monthly
  Unique Total Unique Total Unique Total
Average 22.6 32.3 109.2 160.5 671.8 879
Current 31 52 31 52 31 52
Previous 23 26 180 251 736 1062
Nov 29 22 33 173 249 831 1175
Nov 28 27 36 0 0 805 1052
Nov 27 20 23 152 226 726 910
Nov 26 29 37 0 0 814 1055
Nov 25 31 48 204 299 1001 1286
Nov 24 0 0 0 0 0 0
Nov 23 28 48 160 234 909 1139
Nov 22 15 20 192 294 865 1059
Highest 53 74 242 320 1001 1286


Script Execution Time: 1.6518 | SQL Queries: 10 | Members: 501
Ajax Tutorial Top List - Powered by Aardvark Topsites PHP 5.1.2