Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2014-07-28 23:31:50

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: ... ask anti-spam question on *contact* form?

I included in my forms many tests, for example:

<label for="question">Please the result as a number: Three multiplied by two are ...</label>
<input type="text" id="question" name="question" maxlength="1" value="<?php echo $_POST['question']; ?>" />

It’s made invisible by Javascript (external jQuery file).

Other part:

<input type="hidden" id="monkey" name="monkey" value="<?php if(empty($_POST['monkey'])) echo "0"; else echo $_POST['monkey']; ?>" />

Its value is changed by Javascript (external jQuery file), when a user focus a field:

$("form input").focus(function() {
	$("#monkey").val(["sapiens"]).stop();
});

In the PHP script exist many checks, for example:

	if ((!isset($_SERVER['HTTP_USER_AGENT'])) && (!$_SERVER['REQUEST_METHOD'] == "POST")) { 
		die("Unauthorized use from this form!"); 
		exit;
	}
	elseif (($_POST['monkey'] != "sapiens") && ($_POST['question'] != "6")) {
		$comment = "Uppps! - Something is wrong here.";
		(…)
	}
	(…)

Until now it works fine.

Offline

Board footer

Powered by FluxBB