Sponsered Links
Categories
Sponsered Links

Ajax Registration Page Example

 

This is a simple Ajax Registration Page Example.

<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>
        </center>
    </body>
</html>

Register.php

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

 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved