{"id":2446,"date":"2015-05-01T13:59:32","date_gmt":"2015-05-01T13:59:32","guid":{"rendered":"http:\/\/www.sitekickr.com\/blog\/?p=2446"},"modified":"2015-04-29T14:06:20","modified_gmt":"2015-04-29T14:06:20","slug":"coldfusion-timestamp-trick-prevent-form-spam","status":"publish","type":"post","link":"https:\/\/www.sitekickr.com\/blog\/coldfusion-timestamp-trick-prevent-form-spam\/","title":{"rendered":"ColdFusion timestamp trick to prevent form spam"},"content":{"rendered":"<p>I&#8217;ve been using the &#8220;timestamp trick&#8221; to reduce form submission spam for the past few months now. It&#8217;s been extremely effective!<\/p>\n<p>Today was the first time I had to employ it on a ColdFusion-based site. The basic principle is the same, but it isn&#8217;t readily apparent how to obtain the timestamp.<\/p>\n<p>The following code illustrates it&#8217;s use:<\/p>\n<p>Put this on your form page:<\/p>\n<pre><code>&lt;input name=\"ts\" type=\"hidden\" value=\"#DateDiff(\"s\", CreateDate(1970,1,1), NOW())#\"&gt;<\/code><\/pre>\n<p>Put this at the top of your processing page:<\/p>\n<pre><code>&lt;cfset currentTime = DateDiff(\"s\", CreateDate(1970,1,1), NOW())&gt;\r\n   &lt;cfif currentTime - form.ts lt 3&gt;\r\n   &lt;cflocation url=\"\/\"&gt;\r\n   &lt;cfabort&gt;\r\n&lt;\/cfif&gt;<\/code><\/pre>\n<p>That&#8217;s it!<\/p>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The timestamp trick is a very effective way to prevent form spam. This quick post illustrates how to employ it on a ColdFusion based site.<\/p>\n","protected":false},"author":1,"featured_media":2448,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"amp_status":""},"categories":[34],"tags":[],"_links":{"self":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/2446"}],"collection":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/comments?post=2446"}],"version-history":[{"count":4,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/2446\/revisions"}],"predecessor-version":[{"id":2450,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/2446\/revisions\/2450"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/media\/2448"}],"wp:attachment":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/media?parent=2446"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/categories?post=2446"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/tags?post=2446"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}