severndigital Posted November 10, 2008 Share Posted November 10, 2008 anyone have any idea where i can get a tutorial or working script that would help encode and then decode a string .. somewhat like the coca-cola rewards program, but nothing that fancy. thanks, -C Quote Link to comment https://forums.phpfreaks.com/topic/132168-looking-for-rewards-redemption-algorithm/ Share on other sites More sharing options...
Mchl Posted November 10, 2008 Share Posted November 10, 2008 Care to give an example of what you mean? I'm not familiar with coca-cola programs. Quote Link to comment https://forums.phpfreaks.com/topic/132168-looking-for-rewards-redemption-algorithm/#findComment-686952 Share on other sites More sharing options...
severndigital Posted November 10, 2008 Author Share Posted November 10, 2008 baisically Coca-Cola .. the soda company prints a code on the bottle caps. you go to a website and type it in. if it matches a winning code you win. I am looking to create a code and then when a user enters the code it has a point value i wasn't looking for a total solution per say, just a point in the correct direction. Thanks, C Quote Link to comment https://forums.phpfreaks.com/topic/132168-looking-for-rewards-redemption-algorithm/#findComment-686962 Share on other sites More sharing options...
.josh Posted November 10, 2008 Share Posted November 10, 2008 I don't think you're really going to find a specific tutorial like this. I mean, the concept is pretty simple: make any kind of algorithm that creates random or pseudo-random numbers/strings, let it run a few times to get a couple codes generated and store them as your "winning" codes. Then just have your script run for each person to get their code. If it happens to generate the same code as one of the ones you stored, you have a winner. I mean in principle, it's like playing the "pick a number from 1-100 and I'll guess it" game, except each person only gets 1 guess. Very simple numeric example: // numbers I decided would be winning numbers. $winners = $array(4,20,82); $num = rand(1,100); if (in_array($num, $winners)) { echo "winner!" } As far as having more than one winner, you would just keep track of the numbers you hand out to people, and check if that number has already been generated yet. Pick another number if it's already been passed out once if you want one winner, or keep track of how many times that number has been generated and skip it after 2 times or 10 times or x times, depending on how many winners you want. Quote Link to comment https://forums.phpfreaks.com/topic/132168-looking-for-rewards-redemption-algorithm/#findComment-686971 Share on other sites More sharing options...
severndigital Posted November 10, 2008 Author Share Posted November 10, 2008 yeah .. i'm finding that out. the good news is, i am putting in to a class as i code it. I'll make it available for anyone else that could need it. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/132168-looking-for-rewards-redemption-algorithm/#findComment-687035 Share on other sites More sharing options...
.josh Posted November 10, 2008 Share Posted November 10, 2008 yeah .. i'm finding that out. the good news is, i am putting in to a class as i code it. I'll make it available for anyone else that could need it. Thanks. LoL well you may have a tough time getting people to use it. I mean, if someone knows your algorithm they could possibly increase their odds of finding the winning number....maybe. Really depends on how you go about programming in the "odds" Quote Link to comment https://forums.phpfreaks.com/topic/132168-looking-for-rewards-redemption-algorithm/#findComment-687095 Share on other sites More sharing options...
ddrudik Posted November 12, 2008 Share Posted November 12, 2008 baisically Coca-Cola .. the soda company prints a code on the bottle caps. you go to a website and type it in. if it matches a winning code you win. I am looking to create a code and then when a user enters the code it has a point value i wasn't looking for a total solution per say, just a point in the correct direction. Thanks, C In your design plan for the system, how would "points" be applied to a given "code" value? Maybe given an example of what you want specifically. Quote Link to comment https://forums.phpfreaks.com/topic/132168-looking-for-rewards-redemption-algorithm/#findComment-688160 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.