How to generate random captcha text in ColdFusion

CFimage - generate random captcha text

cfimageCaptchaRandomText.cfm


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>cfimage: how to generate random captcha text in coldfusion</title>
</head>

<body>
<h2 style="color:OrangeRed; font-style:italic">cfimage tag example: how to generate random captcha text</h2>
<hr width="600" align="left" color="OrangeRed" />
<br />

<cfset MyRandomNumber=RandRange(1000,10000)>
<cfset MyRandomText1="CF#MyRandomNumber#">

<cfset MyRandomNumber=RandRange(1000,10000)>
<cfset MyRandomText2="CF#MyRandomNumber#">

<cfset MyRandomNumber=RandRange(1000,10000)>
<cfset MyRandomText3="CF#MyRandomNumber#">

<table border="1" cellpadding="5" cellspacing="0" bordercolor="SeaGreen">
    <tr bgcolor="DarkSeaGreen" style="color:Snow; font-size:large" align="center">
        <td>
            captcha random text
        </td>
        <td>
            captcha random text
        </td>
        <td>
            captcha random text
        </td>
    </tr>
    <tr height="75" valign="top" style="color:RosyBrown; font-weight:bold">
        <td >
   <cfimage 
             action="captcha"
                difficulty="medium"
                text="#MyRandomText1#" 
                />
        </td>
        <td>
   <cfimage 
             action="captcha"
                difficulty="medium"
                text="#MyRandomText2#" 
                />
        </td>
        <td>
   <cfimage 
             action="captcha"
                difficulty="medium"
                text="#MyRandomText3#" 
                />
        </td>
    </tr>
</table>

</body>
</html>





More ColdFusion examples