So I have a website where you can register and use a specific registration code. However I want to limit the total use of the registration code to only 20 times. So the first 20 people who use it will get it, and then it'll be locked out meaning no one else can use the registration code. So if I have this input field:
Registration code: <input type="text" id="registration_code">
Then I just want to grey the field out, or make it unclickable when the limit has been reached. My idea on how to do this would be to have an ajax call for the text field, which calls a php file that checks the number of times it is used already. The way it would do that is, I would have a specific 1-column table in my database that starts at the value of 0 and increments everytime the code is used. The php can retrieve that number and if it's <=20
then lock else, leave it open.
However, this seems like a very roundabout method, and I was hoping stack had some better ideas. Anyone know how to best deal with this kind of situation?