captcha in coldfusion MX
hi
i have been using code create captcha image our forms. works on 1 of our hosting companies 1 of clients uses hosting company runs on coldfusion mx unable work on. please assist me in letting me know or give me alternative option code.
the code follows
<cffunction name="makerandomstring" returntype="string" output="false"> <cfset var chars = "23456789abcdefghjkmnpqrs"> <cfset var length = randrange(4,7)> <cfset var result = ""> <cfset var = ""> <cfset var char = "">
for(i=1; <= 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 name.<br />">
</cfif>
<cfif not len(trim(form.comments))>
<cfset errors = errors & "you must include comments.<br />">
</cfif>
<cfif hash(ucase(form.captcha)) neq form.captchahash>
<cfset errors = errors & "you did not enter right text. spammer?<br />">
</cfif>
<cfif errors "">
<cfset showform = false>
</cfif>
</cfif>
<cfif showform>
<cfset captcha = makerandomstring()>
<cfset captchahash = hash(captcha)>
<cfoutput>
<p>
please fill 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 submitting information, #form.name#.
</p>
</cfoutput>
</cfif>
it gives me following error message
the start tag must have matching end tag. explicit end tag can provided adding </cfscript>. if body of tag empty can use shortcut <cfscript .../>.<p>the cfml compiler 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
More discussions in Advanced Techniques
adobe
Comments
Post a Comment