Jump to content

Recommended Posts

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

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. 

 

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"

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.