Jump to content

Unique PIN codes for scratch cards


dakomeah

Recommended Posts

Hi Everybody,

                    Pls i would like to develop an algorithm to generate pin codes which will be used for making scratch cards for commercializing certain services on a website. I would like to know if there is any material anywhere, that i can read to guide me, or anyone who has handled such a project before can put me in the right direction.

 

The  specifications are.

 

It must be a 14 digit code,

Generated Non sequentially,

However there much be a way of validating it, as different pin codes will be generated for different regions, such that a pin code bought in one region can only be used in making queries about only that region, and not any other.

 

Thank you

Link to comment
Share on other sites

  • 1 month later...

you could generate random numbers between certain values for certain regions. example region a will have numbers between 10000000000000 and 19999999999999, region b will have a random number between 20000000000000 and 29999999999999, and so on....

 

then you could apply a switch and figure out what region they are in.

 

example:


$region = "north"; // put the region of the user here
switch($region){
case "north":
$pin = rand(10000000000000, 19999999999999);
break;
case "south":
$pin = rand(20000000000000, 29999999999999);
break;
}

switch($pin){
case ($pin >= 10000000000000 && $pin <= 19999999999999):
echo "you are in the north";
break;
case ($pin >= 20000000000000 && $pin <= 29999999999999):
echo "you are in the south";
break;
}

Link to comment
Share on other sites

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.