PHP hashing input field names

donnaswan

New Member
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 1Is 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:\[code\]$time = mktime(); $first_name = md5($time + 'first_name'); \[/code\]HTML on the form:\[code\]<form action="register.php" method="post"><input type="text" name="<?php echo $first_name ?>" ><input type="hidden" name="check" value="http://stackoverflow.com/questions/10551696/<?php echo $time ?>" ><input type="submit" name="register"></form>\[/code\]Register.php\[code\]// check to see if there is a timestampif (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? }}\[/code\]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.
 
Back
Top