views:

335

answers:

1

I know Coldfusion 8 and 9 should be able to run PHP codes; although I have not testing this yet. I would like to know if is possible to use JQuery Fancy Captcha: http://www.webdesignbeach.com/beachbar/ajax-fancy-captcha-jquery-plugin in a ColdFusion application. If yes, how could it be implemented?

Thanks Vicente

+2  A: 

All server job described in this quote:

It calls captcha.php file and gets a random number. Php file just generates simple number and put it in session. When AJAX got that number it creates items based on that number.

So here's a quick and not really tested port of their PHP example in CFML:

<cflock scope="session" type="exclusive" timeout="5">

    <cfif StructKeyExists(form, "captcha") AND StructKeyExists(session, "captcha") AND form.captcha EQ session.captcha>

        <!--- YOUR CODE GOES HERE --->
        Passed!

        <!--- this line makes session free, we recommend you to keep it --->
        <cfset StructDelete(session, "captcha") />

    <cfelseif StructKeyExists(form, "captcha")>

        Failed!

    <cfelse>

        <!--- in case that form isn't submitted this file will create a random number and save it in session --->

        <cfset session.captcha = RandRange(0,4) />
        <cfoutput>#session.captcha#</cfoutput>

    </cfif>

</cflock>

Please note that geenrated range from 0 to 4 is not really good, because of its small size (repeats often). But maybe it is just enough for this case.

Sergii
Thank you Sergii, but, how can I use this in my coldfusion 9 site?Thanks
vnzeelomba
Sorry, but if you don't know how to use this in your (your?) site, you should start with CFML basics. Good starting point is here http://www.carehart.org/cf411/#dochelp
Sergii