Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Ajax Ajaxlogin Ajax Registration Program

Related Tutorials


 
 

Share on Google+Share on Google+

Ajax Registration Program

Advertisement
In this Ajax Registration program you will learn how to validate the user registration through ajax call and then display the alert massage if no values are provided in the username and password fields.

Ajax Registration Program

     

In this Ajax Registration  program you will learn  how to validate the user registration through ajax call and then display the alert massage if no values are provided in the username and password fields.

When a user input user Id and password and press Register button , method 'call_Register()'  will make ajax call. If  the value returned from the server is "yes" the alert box will show 'Welcome for Register' otherwise it will show ' the Invalid Id/password please enter the Id/password!'. 

Example of  Ajax Registration program:

<html>

  <head>

  <title>Ajax Registratiion program</title>

  <script language="javascript">

  function postRequest(strURL){

var xmlHttp;

if(window.XMLHttpRequest){ // For Mozilla, Safari, ...

var xmlHttp = new XMLHttpRequest();

}

else if(window.ActiveXObject){ // For Internet Explorer

var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");

}

xmlHttp.open('POST', strURL, true);

xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

xmlHttp.onreadystatechange = function(){

if (xmlHttp.readyState == 4){

updatepage(xmlHttp.responseText);

}

}

xmlHttp.send(strURL);

}
function updatepage(str){

if(str == "no"){

   alert("Invalid Id/password! Please fill Currect Id/password")

}
   else{

  alert("welcome for register !");

  }

   }

function call_register(){

var login_id =document.reg.uid.value;

  var password=document.reg.passwd.value;

var url = "Register.php?loginid="+login_id+"&password="+password+"";

postRequest(url);



  </script>

  </head>

  <body> 

  <center>

 <form name="reg">

  <table border="1" width="30%">

  <tr>

   <td align="center" colspan="2">  <font face="Monotype" size="5">Registration</font></td>

  </tr>

  <tr>

  <td>  Login id: </td>  <td> <input type="text" name="uid"  size="20"></td>

  </tr>

 <tr> 

  <td> Password: </td><td><input type="password" name="passwd" size="20" /></td>

  </tr>

  <tr>

  <td align="center" colspan="2"> <input type="submit"  value="Register" onClick="return call_register()" 

 style="background-color:#FFE9D2;color:#0000FF; border-color:#99CC33"> </td>

  </tr>
  </table>

  </form>

  </body>
  </html>

Here this code support the Register.php for Ajax Registration program:

<?
$loginid=$_GET["loginid"];
$password=$_GET["password"];
if( $password == "" || $loginid == "" || ($loginid == "" && $password == "") ){
echo "no";
}
else{
echo "yes";
}
?>

Try the Example online

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 23, 2006

Related Tutorials

Discuss: Ajax Registration Program  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
Thirumurugan
June 4, 2012
Error

Add return false; in call_register
DMCA.com