I have been reading this blog post and this stack overflow post but I don't have much experience with hashing form fields (the honeypot part, there seems to be a lot of examples on the web) So I have a few questions.
Question 1
Is it something like this or am I way off base? (Note, this is a simplified example with just the timestamp for brevity)
PHP on the form:
$time = mktime();
$first_name = md5($time + 'first_name');
HTML on the form:
<form action="register.php" method="post">
<input type="text" name="<?php echo $first_name ?>" >
<input type="hidden" name="check" value="<?php echo $time ?>" >
<input type="submit" name="register">
</form>
Register.php
// check to see if there is a timestamp
if (isset($_POST['check'])) {
$time = strtotime($_POST['check']);
if (time() < $time) {
// original timestamp is in the future, this is wrong
}
if (time() - $time < 60) {
// form was filled out too fast, less than 1 minute?
}
// otherwise
$key = $_POST['check'];
if (md5($key + 'first_name') == $_POST['whatever-the-hash-on-the-first_name-field-was']) {
// process first_name field?
}
}
Question 2:
How does the hashing of the field name make things more secure? I get the timestamp check (although I don't understand the part in the blog post "too far in the past"...wouldn't a bot fill it out too fast if anything??) but I am not sure what hashing the name attribute does exactly.