We have a MySQL database with a table called "keys". It contains "ID" and "Key." We already have php code that will verify (and optionally delete too) entries (a.k.a. coupon codes) in that table. We also have php code that will write random coupon codes into the table. However, WHAT WE NEED is php code that gives a user the ability to create a sequential number range of numeric coupon codes, and for that range to be configurable through a web form.
A screenshot of the database table is attached (We manually entered in sequentially numbered entries to demonstrate what the final product needs to do).
We would like for our client to be able to create a numeric range of coupon codes from, for example, 1000001 to 2000000 (or whatever number range they choose). Here is a crude diagram of the web form:
Create Coupon Codes
Number Range Minimum: [TEXT BOX]
Number Range Maximum: [TEXT BOX]
Next, we will need the ability to take one of those coupon codes (with the option of only using each coupon code once), and do something with it. For right now, we would like a public web form that asks for the visitor's name and email address, and upon successful submission and/or redirection to a new page, it then emails a coupon code to the address entered into the form. It also should post the form data info another table in our database. We also need to prevent the same email address from getting more than 1 coupon.
Enter your email address and we will
send you a coupon code.
Email Address: [TEXT BOX]
Once we have those things in place, we'll have the ability to help our clients in the following scenario:
Restaurant general manager, Chris, would like to do an online customer survey to gather feedback from customers. The survey is very long, so he needs to give away a pretty substantial incentive to get people to fill out the survey. He's decided to give away a coupon for two free draft beers to those who complete the survey. You complete the
survey, and the system emails you a coupon. Of course this all needs to be automated, but the problem with most automated responses is that they are limited to static content, meaning everyone that completed the
survey would get the exact same email. The coupon would be the same for everyone, and Chris would have no way of telling if the coupon was redeemed more than once. This is not that big of a deal for small coupons like 10% off, but for coupons such as Two Free Drafts, it's a problem and will be abused. Chris needs the ability to make "single use" coupon codes and automate their delivery...
Chris needs to:
1. Specify a custom range of coupon code numbers, and post every number in that range to the "keys" table in his database.
2. Give his guests a web form, and if they submit the form successfully, they will get an automated email with one of the coupon codes generated in step one (a random one from within that range). Once that coupon code has been emailed to someone, it will not be emailed to anyone else.
3. Have a web form on his end where he can enter a customer's redeemed coupon code to validate it. One the code has been used once, it will no longer be valid (deleted from the database).
We already have the php code for number three on that list. We just need code for the ability to perform steps one and two.
here is the referred to php code hosted (also attached)...
[url removed, login to view]
[url removed, login to view]
We do NOT want any design work or extensive css styling added. Keep it as basic as possible, and we will add the design.
You are welcome to not use the attached code if it will be faster for you (and less expensive for us) to complete this project. We only purchased this code to lower the overall cost of the project, but if that is not the case, we have no other reasons to keep the code and it can be discarded.