First of all, and really sorry to say, but this is unlikely to work.
You want first to find out if a user is allowed to participate.
So you need a SELECT statement.
Your INSERT statement will just insert, returning either sucess or failure.
The insert statement does not check for duplicates unless you use a primary key made of the userid AND the date.
And next, on success it will always return 1, so your script will tell [everybody to be the first..
Last, the check for the "submit" value is not a useful means to find out if somebody comes from a certain page.
You need to work with $_SERVER['HTTP_REFERER'] there, which again has issues with certain firewalls.
The German PunBB Site:
PunBB-forum.de