What about using:

<cfif ("form.submit")>

put the captcha2 action stuff in here

<cfelse>

put the stuff to been seen if the form isnt submitting in here

</cfif>




> This code is taken from the CF docs for CF 9.
> 
> I am trying to update our old forms to use cfimage to verify. Once I 
> can get the image to work, I can update the forms. However the issue 
> is I have to link to the form on the action page. could this all me 
> done in one page, or is there a better way?
> 
> <!---captcha1--->
> <!--- Set the length of the text string for the CAPTCHA image. ---> 
> <cfset stringLength=6> 
> <!--- Specify the list of characters used for the random text string. 
> The following list 
    
> limits the confusion between upper- and lowercase letters as well as 
> between numbers and 
    
> letters. ---> 
> <cfset 
    
> stringList="2,3,4,5,6,7,8,9,a,b,d,e,f,g,h,j,n,q,r,t,y,A,B,C,D,E,F,G,H,
> K,L,M,N,P,Q,R,S, 
    
> T,U,V,W,X,Y,Z"> 
> <cfset rndString=""> 
> <!--- Create a loop that builds the string from the random characters. 
> ---> 
> <cfloop from="1" to="#stringLength#" index="i"> 
    
> <cfset rndNum=RandRange(1,listLen(stringList))> 
    
> <cfset rndString=rndString & listGetAt(stringList,rndNum)> 
> </cfloop> 
> <!--- Hash the random string. ---> 
> <cfset rndHash=Hash(rndString)> 
 
> 
> <!--- Create the user entry form. ---> 
> <cfform action="captcha2.cfm" method="post"> 
> 
> <!--- Use the randomly generated text string for the CAPTCHA image. 
> ---> 
> <p><cfimage action="captcha" fontSize="16" fonts="Times New Roman" 
> width="215" height="50" 
    
> text="#rndString#"></p> 
> <p>Please type what you see: </p> 
> <p><cfinput type="text" name="userInput" required="yes"> 
> <cfinput type="hidden" name="hashVal" value="#rndHash#"> 
> <p><cfinput type="Submit" name ="OK" value="OK"></p> 
> </cfform>
> 
> 
> <!--- captcha2--->
> 
> <!--- Verify whether the text entered by the user matches the CAPTCHA 
> string. ---> 
> <cfif #form.hashval# eq Hash(#form.userInput#)> 
    
> <cfoutput> 
>               you got it!
    
> </cfoutput> 
> <cfelse> 
    
> <p>I'm sorry; please try again.</p> 
    
> <a href="captcha1.cfm">go back to form</a>
    
> 
> </cfif>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:5257
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-newbie/unsubscribe.cfm

Reply via email to