EasyCFM.COM ColdFusion Forums / Tutorial Requests! / what about login check module using ajax

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: what about login check module using ajax

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

specific
01-18-2008 @ 1:43 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 897
Joined: Apr 2006

hi, i was thinking how could it be nice to have atutorial like:

check username avaliability before posting data to the database using AJAX and Coldfusion.

i have seen this on many websites but unfortunately i tried but i cdid not succeded

well i am still trying and lets hope i do it by one day

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Door to Coldfusion Community Will Remain Open Till World Ends

Want a Web Portal Contact Me

randhawaz81@gmail.com

<cf_visitwebsite>

http://portal.randhawaworld.com/

</cf_visitwebsite>

louissto56
01-18-2008 @ 5:28 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1149
Joined: Jan 2007

Thats funny. I just suggested my mate daveED that he should do a tutorial on that. Maybe he will now. I'll ask him.

Louis

____________________________
My Biz List.com.au :: Feb 08

specific
01-22-2008 @ 1:01 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 897
Joined: Apr 2006

hey Thanks

My little snippets could help daveED in preparing a tutorial if he/she likes:

here is the code:

<script language="javascript">
function OnChangedUsername()
{
if(document.form1.newuserid.value == "")
{
document.form1.btnCheckAvailability.disabled = true;
}
else
{
document.form1.btnCheckAvailability.disabled = false;
}
}

function OnCheckAvailability()
{
if(window.XMLHttpRequest)
{
oRequest = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
oRequest = new ActiveXObject("Microsoft.XMLHTTP");
}

oRequest.open("POST", "checkavaliability.cfm", true);
oRequest.onreadystatechange = UpdateCheckAvailability;

oRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
oRequest.send("strCmd=availability&strUsername=" + document.form1.newuserid.value);
}

function UpdateCheckAvailability()
{
if(oRequest.readyState == 4)
{
if(oRequest.status == 200)
{
document.getElementById("Available").innerHTML = oRequest.responseText;
}
else
{
document.getElementById("Available").innerHTML = "Asychronous Error";
}
}
}
</script>


then in the form tag

<tr>
              <td width="23%"><input name="newuserid" type="text" id="newuserid" size="35"
                 onKeyUp="OnChangedUsername();" value="#form.newuserid#" />
                *</td>
              <td width="77%"><input id="btnCheckAvailability" type="button" disabled="disabled"
            value="Check Availability" onClick="OnCheckAvailability();" /></td>
            </tr>
            <tr>
              <td colspan="2"><div ID="Available"></div></td>
            </tr>

the action page:

checkavaliability:

<cfswitch expression="#strCmd#">
<cfcase value="avaliability">
<cfquery datasource="#dsn#" name="check">
SELECT uniquename FROM
registration
WHERE
uniquename = '#TRIM(strUsername)#'
</cfquery>
<cfif check.recordcount GT 0>
     <cfset msg = "Username Already Taken">
<cfelse>
     <cfset msg = "Username is avaliable">
</cfif>
</cfcase>
</cfswitch>

but i must say i have some bugs. don't know where, it is just returning the asuncronous error.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Door to Coldfusion Community Will Remain Open Till World Ends

Want a Web Portal Contact Me

randhawaz81@gmail.com

<cf_visitwebsite>

http://portal.randhawaworld.com/

</cf_visitwebsite>


Website Designed and Developed by Pablo Varando.