Create CAPTCHA or Random Word In Coldfusion.

This is simple program to generate random word or CAPTCHA code in coldfusion.


<cfoutput>
<cfset randNums1 = RandRange(2,9)>
<cfset randNums2 = RandRange(2,9)>
<cfset randNums3 = RandRange(2,9)>
<cfset randNums4 = RandRange(2,9)>
<cfset randNums5 = RandRange(2,9)>
<cfset alphas = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,P,Q,R,S,T,U,V,W,X,Y,Z">
<cfset randChar1 = RandRange(1,25)>
<cfset randChar2 = RandRange(1,25)>
<cfset randChar3 = RandRange(1,25)>
<cfset randChar4 = RandRange(1,25)>
<cfset randAlpha1 = ListGetAt(alphas,randChar1,',')>
<cfset randAlpha2 = ListGetAt(alphas,randChar2,',')>
<cfset RandomChars = "#randAlpha1##randNums1##randAlpha2##randNums2##randNums3##randChar3##randChar4##randNums5#">
<form action="#CGI.script_name#" method="post">
<!---
This is the hidden field that will flag form
submission for data validation.
--->
<input type="hidden" name="submitted" value="1" />
<!---
This is the hidden field that we will check the
user's CAPTCHA text against. This is an encrypted
field so that spiders
--->
<input type="hidden" name="captcha_check" value="#RandomChars#" >
<p>
<cfimage action="captcha" height="75" width="363" text="#RandomChars#" difficulty="medium"
fonts="verdana,arial,times new roman,courier" fontsize="28" />
</p>
<label for="captcha">
Please enter text in image:
</label>
<input type="text" name="captcha" id="captcha" value="" />
<input type="submit" value="Submit" />
</form>
</cfoutput>
view raw captcha.cfm hosted with ❤ by GitHub

OutPut : -

Comments

Popular posts from this blog

Login with facebook using coldfusion

Create CSV file in Coldfusion Using CFFile

Get Previous One Day Data in Sql Server