I want to create a web page where a registered user picks a number from 1 to 10. When a user picks a number that number is removed from the available list.
Is there a way to guaranty that no 2 or more users can have the same number?
Thanks,
rod
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I dont know how to do it in the technologies in your tags, but you will need a database, that keeps the state of each number: taken or free. You will have a form on a page, that will submit the number chosen to a form handler that will check the state of the number in the database. If it is taken, you will send the user a page that says “too bad thats taken” or something, if it is free, you will mark it as taken, then send then a page saying they got it.
Your server probably handles requests on a first come first serve basis, and if you use any modern database it will block for you (you just wouldn’t want two people trying to get the same number at the same time)
also, the form and the form handler don’t have to be different files
and you probably want to record who took what number, so the state of not being taken might was well be the state of not having a username for the number yet.