Page 1 of 1

Applying more than one password to a form

Posted: Mon Jul 14, 2008 2:34 am
by Addos
Hi,
I’m looking for some pointers as to how to setup the following. I have a single form field that I’m using as a type of discount so that when a code(password) is entered a specific total is taken off a price. My problem is that I want to be able to have a couple of discounts available so that more than one can be entered at a time.

So the table in my database would have fields that contain a few unique codes - for example:
Discount value $20 - code 12345
Discount value $30 - code 54321

I know how to run a loop looking for a specific code but I need to set this up so that if the first code is entered the value is taken off and then if the second code is entered then that is also taken off and so on.

For the moment I just want to get the logic of how to enter a code into the form print (echo) this out on another page and then add the second code and see this along with the first code on the same page. Should I be using Sessions?

If anyone can give me a few pointers as to how to go about this I’d be very grateful.

Re: Applying more than one password to a form

Posted: Mon Jul 14, 2008 3:47 am
by Apollo
Just store an array of used discount codes in a cookie. That way you can calculate the total discount at any time, and if the user leaves the site and comes back, his coupons are still rememberd (unless he wipes cookies of course).

For security measures:
- make 'unguessable' discount codes, or better yet, encrypt the cookie data
- of course make sure you don't apply a discount code if it's already in the list (unless you want people to use the same discount more than once)