I am trying to set up a form/database to be used for a give away contest. The contest will be set up where a claim code will be sent out to an email distribution list. The first person to enter their name, email address and the code will win whatever prize is associated with the code.
table_1 will store the prize information (name, description, claim code, etc). This will be populated before the email goes out to the distribution list.
table_2 will only store the winner’s information.
The form will have to check not only that the claim code is correct by it’s existence in table_1, but also that it does not already exist in table_2.
I’m looking to create a form that does a few things:
1 - Allows a user to enter certain information (name, email address, claim code) - this part is easy, not concerned with coding the form. Just included it to give the full picture.
2 - Checks to see if the claim code the user entered is stored in table_1 of a MySQL database.
3a - If the claim code is in table_1, then the user’s form data (name, email address, and claim code) is saved to table_2 of the same database.
3b - If the claim code is not stored in table_1, then it displays an error message to the user stating that the code they entered is incorrect. The form would be re-displayed and the user would be prompted to try again. Nothing would get stored in table_2 until a correct validation code was entered.
4 - Once a user enters the correct claim code, that code is no longer valid for future users to submit.
I already have the database set up. I’m just looking for the code to process all the data.
Is there an easier way to do this? Does something like this already exist, or is there something similar available that I haven’t found yet?
Thanks in advance.