Last active
August 29, 2015 13:57
-
-
Save mcbrwr/9767784 to your computer and use it in GitHub Desktop.
form spam protection - the easy way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('form :text').keydown(function(){ | |
if (!$(this).parents('form').children('.pl').length) { | |
var d = new Date(); | |
var n = d.getDay()*d.getDate(); | |
$(this).parents('form').append('<input type="hidden" name="pl" class="pl" value="'+n+'">'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( $_POST && isset($_POST['pl'] && $_POST['pl']== date('w')*date('j') ) ) { | |
// treat form | |
} else { | |
die('you just died. insert coin to continue'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BIG disadvantage (i admit) is that without JS sending of the form is not possible. I was thinking of combing his with a php hidden field that's inserted if a valid referrer page is found.