Aim:-To Study AJAX and PHP For Form Validation. Theory Ajax
Aim:-To Study AJAX and PHP For Form Validation. Theory Ajax
Theory :
AJAX:
1. Ajax (shorthand for Asynchronous JavaScript and XML) is a group of
interrelated web development techniques used on the client-side to create
interactive web applications. With Ajax, web applications can retrieve data
from the server asynchronously in the background without interfering with
the display and behavior of the existing page. The use of Ajax techniques
has led to an increase in interactive or dynamic interfaces on web pages.
Data is usually retrieved using the XMLHttpRequest object. Despite the
name, the use of XML is not actually required, nor do the requests need to
be asynchronous.
2. Like DHTML , Ajax is not a technology in itself, but a group of
technologies. Ajax uses a combination of HTML and CSS to mark up and
style information. The DOM is accessed with JavaScript to dynamically
display, and to allow the user to interact with the information presented.
JavaScript and the XMLHttpRequest object provide a method for
exchanging data asynchronously between browser and server to avoid full
page reloads.
XMLHTTP:
1. XMLHTTP was first introduced as a Microsoft ActiveX control in Microsoft
Internet Explorer 5. Over time, this object has been implemented by other
browsing platforms and is the cornerstone of Web applications based on
Asynchronous JavaScript and XML (AJAX).
2. The XMLHTTP object enables the browser to send and receive
asynchronous, out-of-band HTTP requests to the Web server, which
responds with XML. The response can be manipulated with client-side script
or transformed with Extensible Style sheet Language Transformations
(XSLT). XMLHTTP makes it possible to create responsive Web
applications that do not have to refresh the entire page to display new data.
3. XMLHTTP can be thought of as an XML-based response/request protocol,
which allows us to send text/xml to a remote server. That server processes
the request, and in-turn, returns either a text/XML data stream or a binary
stream of characters.
JS functions:
1. document.getElementById: Returns the element whose ID is specified. If
more than one element is found, getElementById returns the first object in
the collection.
2. innerHTML: The innerHTML property sets or returns the inner HTML of an
element.
AJAX Functions:
PHP Functions:
1. require_once: The require once() statement is identical to require() except PHP will
check if the file has already been included, and if so, not include it again.
2. $_GET: The built-in $_GET function is used to collect values in a form with
method="get".Information sent from a form with the GET method is visible to everyone
(it will be displayed in the browser's address bar) and has limits on the amount of
information to send (max. 100 characters).
3. die(): It is executed if connection fails.
4. mysql_num_rows(): The mysql_num_rows() function returns the number of rows in a
recordset . This function returns FALSE on failure
5. echo: The echo() function outputs one or more strings. The echo() function is not
actually a function, so it is not required to use parentheses with it. However, if we want
to pass more than one parameter to echo(), using parentheses will generate a parse error.
6. mysql_query: The mysql_query() function executes a query on a MySQL database.This
function returns the query handle for SELECT queries, TRUE/FALSE for other queries, or FALSE
on failure.
Applications and Implications :
There are various applications of using AJAX for creating web pages. It allows
web pages to be updated asynchronously without needing it to be reloaded. It
exchanges small part of data with web server. This all process is done behind the
scene. The main power of AJAX lies in creating XMLHttpRequest object. This
object is responsible for dynamic updates without reloading web pages.
AJAX can be used for interactive communication with XML file, with databases.
Form validation is important process as it avoids wrong information gathering
and storing it in databases. User input should be validated on the browser
whenever possible. This reduces load in server. At the same time we have to make
sure that user sensitive information like passwords should not be validated on
client side.
In ecommerce scenario form validation is important as it will avoid wrong
information from being entered. So it will help to understand customer correctly
and effectively. As it avoids page reloading each time user enters information and
moves to next field at that instant only previous field is checked so user feels it
very interactive. Quick reponse can be given.
Conclusion :