1 Reply Latest reply on Apr 16, 2010 8:30 AM by codemonkeysteve

    captcha in coldfusion MX

    cybertek23 Level 1


      I have been using a code to create a captcha image for our forms. It works on one of our hosting companies but one of my clients uses a hosting company that only runs on coldfusion MX which it is unable to work on.  Could someone please assist me in letting me know or give me an alternative option for this code.


      The code is as follows


      <cffunction name="makeRandomString" returnType="string" output="false">

           <cfset var chars = "23456789ABCDEFGHJKMNPQRS">

           <cfset var length = randRange(4,7)>

          <cfset var result = "">

           <cfset var i = "">

         <cfset var char = "">



            for(i=1; i <= length; i++) {

                char = mid(chars, randRange(1, len(chars)),1);




            <cfreturn result


        <cfset showForm = true>

        <cfparam name="form.name" default="">

        <cfparam name="form.comments" default="">

        <cfparam name="form.captcha" default="">

        <cfparam name="form.captchaHash" default="">

          <cfif isDefined("form.send")>

            <cfset errors = "">

            <cfif not len(trim(form.name))>

                <cfset errors = errors & "You must include your name.<br />">


            <cfif not len(trim(form.comments))>

                <cfset errors = errors & "You must include your comments.<br />">


            <cfif hash(ucase(form.captcha)) neq form.captchaHash>

                <cfset errors = errors & "You did not enter the right text. Are you a spammer?<br />">


            <cfif errors is "">

                        <cfset showForm = false>



        <cfif showForm>

           <cfset captcha = makeRandomString()>

            <cfset captchaHash = hash(captcha)>



            Please fill the form below.


           <cfif isDefined("errors")>


            <b>Correct these errors:<br />#errors#</b>



            <form action="#cgi.script_name#" method="post" >




                    <td><input name="name" type="text" value="#form.name#"></td>




                    <td><textarea name="comments">#form.comments#</textarea></td>



                    <td>Enter Text Below:</td>

                    <td><input type="text" name="captcha"></td>



                    <td colspan="2">

                    <cfimage action="captcha" width="300" height="75"


                    <input type="hidden" name="captchaHash" value="#captchaHash#">




                   <td> </td>

                    <td><input type="submit" name="send" value="Send Comments"></td>








            Thank you for submitting your information, #form.name#.





      It gives me the following error Message



      The start tag must have a matching end tag. An explicit end tag can be provided by adding &lt;/cfscript&gt;. If the body of the tag is empty you can use the shortcut &lt;cfscript .../&gt;.<p>The CFML compiler was processing:<ul><li>a cfscript tag beginning on line 9, column 8.<li>a

      cfscript tag beginning on line 9, column 8.</ul>   The error occurred in

      E:\WebUsers\www.hvld.co.uk\captcha2.cfm: line 9