I’ve been using the “timestamp trick” to reduce form submission spam for the past few months now. It’s been extremely effective!

Today was the first time I had to employ it on a ColdFusion-based site. The basic principle is the same, but it isn’t readily apparent how to obtain the timestamp.

The following code illustrates it’s use:

Put this on your form page:

<input name="ts" type="hidden" value="#DateDiff("s", CreateDate(1970,1,1), NOW())#">

Put this at the top of your processing page:

<cfset currentTime = DateDiff("s", CreateDate(1970,1,1), NOW())>
   <cfif currentTime - form.ts lt 3>
   <cflocation url="/">
   <cfabort>
</cfif>

That’s it!

Now, any bot that attempts to submit the form in less than 3 seconds will be automatically redirected to your home page, instead of continuing with the processing script.

4 Comments

        1. Much appreciated! To be honest, those articles are often a fallback when I have nothing substantial to post. I didn’t think anyone really read them – so thanks for the note!

          P.S. I post a lot of those kind of tips on Twitter @sitekickr

Leave a Reply to IvanIon Cancel reply

Your email address will not be published. Required fields are marked *