One Time Registration Code

I am trying to create an authentication for a form.

Its like an application. If you don’t enter a code provided by me, you can’t access the form.
Please how do i do that ?

Challenges;

  1. If code is not associated to a user ID, code should still remain valid.
  2. Code should work only once
  3. Two or more users entering code at same time (one must be invalid).

I think you’re causing yourself a big headache by having only one user being able to enter a valid code that is good code at a given time, but turns out that it might be invalid only because someone else beat me to the punch entering it. I know if that happen to me as a user, I would say **** it I’m out here. The validation code(s) should be unique to each individual even if it isn’t tied to an individual user id (again I personally would tie it to an user id, but that’s just me. )