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
https://forums.phpfreaks.com/topic/216144-unique-pin-codes-for-scratch-cards/
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;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.