Hi there, I am have just build my site and the concept is that I have a squeeze page with an attractive free offer. If the visitors opt-in they will be transferred to an one-time-offer product. But I want that this page shows some randomly generated promo codes. If the visitors uses this code they can save 50% or something of the price. I know people love this promo codes and I need a php script or similar that can exactly do that. I looked around but I couldn't find any ... can anyone recommend me promo code script ? Thanks Thomas
Here is a function to show a random generated 6 alphanumeric code.. beyond that you need someone to code something like below to work with your billing/service. <? /* // Example: $promo_code = promoCode(); print $promo_code; */ function promoCode() { // Coded by Levi at boogybonbon.com // Enjoy! return substr(md5(time()), 0, 6); } ?> PHP:
Useful snippet, thanks for sharing. Any way to ensure that the same string of numbers won't be generated twice?
It should not use the same string as its based on a time() value that is always moving forward. However if your storing the codes its not that hard to write a class to manage it all and if the code has already been used reject the code, etc.
Quick example without a working db manager yes: <? while(usedPromos(promoCode())==false); // ^^ -- Its is an endless look that will not move forward untill the code is found without a match. function UsedPromos($code) { // Connect to DB and check Code // If no code return TRUE, otherwise return false. } // Another Example: if(usedPromos(promoCode())==false) { echo "Bad Code"; } else echo "good code"; ?> PHP: