I have an extension to the same idea:
Create a table, we'll call it "input_threads".
create table input_threads (
thread auto_increment primary key,
when date)
(mysql-ish definition, here)
When you have an input form, create a record for that INSTANCE of the form: "insert into input_threads(date) values ('".date('m/d/Y h:i:s', mktime())."')";
Get the "thread" field value and put that into the input form, in a variable called "input_thread".
Then, on the receiving page, do a query to delete the input_thread, "Delete from input_threads WHERE thread=$input_thread", and get a count of the affected tuples. (mysql_affected_rows) and if ==1, go ahead with the login, otherwise spit out the login screen again.
Every so often, do a "delete from input_threads where when < $a_while_ago";
I do this at random, usually based on the clock time being exactly on the minute:
$check=date('s', mktime());
if ($check=='00')
mysql_query("delete from input_thread
where when < $a_while_ago";
Works for me. If you want to get fancy, you can include stuff like the browser version, IP address, etc. in the thread table and check these too.
I think I kinda covered this in my earlier post in this thread, but this should give more detail.
-Ben