Copy link to clipboard
Copied
Hi
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 = "">
<cfscript>for(i=1; i <= length; i++) {
char = mid(chars, randRange(1, len(chars)),1);
result&=char;
}
</cfscript>
<cfreturn result
</cffunction>
<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>
<cfif not len(trim(form.comments))>
<cfset errors = errors & "You must include your comments.<br />">
</cfif>
<cfif hash(ucase(form.captcha)) neq form.captchaHash>
<cfset errors = errors & "You did not enter the right text. Are you a spammer?<br />">
</cfif>
<cfif errors is "">
<cfset showForm = false>
</cfif>
</cfif>
<cfif showForm>
<cfset captcha = makeRandomString()>
<cfset captchaHash = hash(captcha)>
<cfoutput>
<p>
Please fill the form below.
</p>
<cfif isDefined("errors")>
<p>
<b>Correct these errors:<br />#errors#</b>
</p>
</cfif>
<form action="#cgi.script_name#" method="post" >
<table>
<tr>
<td>Name:</td>
<td><input name="name" type="text" value="#form.name#"></td>
</tr>
<tr>
<td>Comments:</td>
<td><textarea name="comments">#form.comments#</textarea></td>
</tr>
<tr>
<td>Enter Text Below:</td>
<td><input type="text" name="captcha"></td>
</tr>
<tr>
<td colspan="2">
<cfimage action="captcha" width="300" height="75"
text="#captcha#">
<input type="hidden" name="captchaHash" value="#captchaHash#">
</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="send" value="Send Comments"></td>
</tr>
</table>
</form>
</cfoutput>
<cfelse>
<cfoutput>
<p>
Thank you for submitting your information, #form.name#.
</p>
</cfoutput>
</cfif>
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 </cfscript>. If the body of the tag is empty you can use the shortcut <cfscript .../>.<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
Thanks
Copy link to clipboard
Copied