» » Use PHP generate a unique membership number

 

Use PHP generate a unique membership number

Author: bamboo06 on 4-11-2014, 03:55, views: 10312

40
When we want a huge number of data, while the median number have restrictions, such as license plate numbers 5, 10 of a document number, serial number of orders, short URL, etc., we can use the 36-ary calculated not repeat the numbers in line with the median.

We will use 0-Z (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ) to represent the values ​​0-35, such as the letter Z represents 35. So I want to get a five numbers, the greatest amount of information is 36 5 th, and 36 ^ 5 = 60,466,176, which is equivalent to the maximum number of five decimal numbers: 60466176.
In order to do presentations in this article, we assume that a group of 10 paid a club membership number, membership number by three city ID card encoding +2 +5 bit checksum components. City number with area code indicated as 755 representatives of Shenzhen, five card numbers from card number consisting of 36 hexadecimal, followed by two check code is generated by a certain algorithm is able to use the checksum to verify the card number legitimacy. In this case, we generate 10 card number corresponds to the maximum to meet the 60 million membership number, and is not repeated unique card number.
PHP
We use PHP to convert hexadecimal, decimal turn 36 hex.

class Code { 
    //Password dictionary
    private $dic = array( 
        0=>'0',    1=>'1', 2=>'2', 3=>'3', 4=>'4', 5=>'5', 6=>'6', 7=>'7', 8=>'8',     
        9=>'9', 10=>'A',  11=>'B', 12=>'C', 13=>'D', 14=>'E', 15=>'F',  16=>'G',  17=>'H',     
        18=>'I',19=>'J',  20=>'K', 21=>'L',  22=>'M',  23=>'N', 24=>'O', 25=>'P', 26=>'Q',     
    27=>'R',28=>'S',  29=>'T',  30=>'U', 31=>'V',  32=>'W',  33=>'X', 34=>'Y', 35=>'Z' 
    ); 
 
 
    public function encodeID($int, $format=8) { 
        $dics = $this->dic; 
        $dnum = 36; //Hexadecimal number
        $arr = array (); 
        $loop = true; 
        while ($loop) { 
            $arr[] = $dics[bcmod($int, $dnum)]; 
            $int = bcdiv($int, $dnum, 0); 
            if ($int == '0') { 
                $loop = false; 
            } 
        } 
        if (count($arr) < $format) 
            $arr = array_pad($arr, $format, $dics[0]); 
 
        return implode('', array_reverse($arr)); 
    } 
 
    public function decodeID($ids) { 
        $dics = $this->dic; 
        $dnum = 36; //Hexadecimal number
        //Key exchange 
        $dedic = array_flip($dics); 
        //Go to zero 
        $id = ltrim($ids, $dics[0]); 
        //trun 
        $id = strrev($id); 
        $v = 0; 
        for ($i = 0, $j = strlen($id); $i < $j; $i++) { 
            $v = bcadd(bcmul($dedic[$id { 
                $i } 
            ], bcpow($dnum, $i, 0), 0), $v, 0); 
        } 
        return $v; 
    } 
 
} 

We define the Code class, define a password dictionary, namely 0-Z corresponding numerical method encodeID ($ int, $ format) in the parameter $ int represents a number, $ format represents the median length, for example encodeID (123456789,5) expressed will be converted into five figures 123456789 36 hexadecimal numbers and methods decodeID ($ ids) is used to convert 36 hex number 10 hex number.
We can do to generate the card:
$code = new Code(); 
$card_no = $code->encodeID(888888,5); 

As above, we can get a five card number, it actually represents the card number is 888888 (6 8), membership number, but the actual conversion is five numbers: 0J1VC.
Next, we check the number and the city code plus the city ID is already defined, the check code through a certain algorithm to obtain, in this case, we use a simple algorithm: The first three numbers and five cities md5 card numbers were encrypted, and then take the first two as md5 checksum value, so get the numbers behind the two checksum.

$card_pre = '755'; 
$card_vc = substr(md5($card_pre.$card_no),0,2); 
$card_vc = strtoupper($card_vc); 
echo $card_pre.$card_no.$card_vc; 

Practical applications, you can get 10 hexadecimal numbers through a database to ensure that Unique numbers, then use the above code combinations, and ultimately generate a 10-bit card number is not repeated.

Category: PHP Scripts / Javascript

Dear visitor, you are browsing our website as Guest.
We strongly recommend you to register and login to view hidden contents.
<
  • 0 Comments
  • 0 Articles
21 June 2017 19:40

davidjoe

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
I have always wondered how this buy movie jackets was redirected to another page. Now I know the way to having the redirect option operate in web development. This has been very informative, thanks!

<
  • 0 Comments
  • 0 Articles
24 July 2017 20:26

nikhil

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Pokemon Go Wont Load, Tutu app won’t won’t Download, Unable to install, these are the general problems tutu app users generally experience tutu app not working

<
  • 0 Comments
  • 0 Articles
27 July 2017 20:19

www.gmail.coim

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
www.gmail.coim This article which helps you to know complete information about www.gmail.com. Nowadays emails are very much important in our day to day life

<
  • 0 Comments
  • 0 Articles
6 September 2017 05:26

saami

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
This is the simple procedure to install TuTu VIP app on your PC devices. You can follow the same procedure to install this application on Mac devices.Read More

<
  • 0 Comments
  • 0 Articles
6 September 2017 22:29

Homepage

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Any add-ons that are geo-restricted most likely requires a Kodi VPN to air channels across different countries. It protects your privacy and also your internet activity. Here is our list of best geo-restricted add-ons:

Homepage

<
  • 0 Comments
  • 0 Articles
7 September 2017 05:08

sara

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Recently I have found a working serial key for hdd regenerator. Hdd regenerator is used to fix bad sectors of hard disk without loosing any data. It is probably the best software to repair hdd bad sectors.It doesn't hide dangerous sectors, it very...
Homepage

<
  • 0 Comments
  • 0 Articles
7 September 2017 22:23

john

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
this is the most awesome app for patching your ads on your mobile. Read More

<
  • 0 Comments
  • 0 Articles
10 September 2017 04:07

Santosh

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Puffin Browser: Puffin browser includes very fast mobile web browser which enables you to save your protected data in the cloud. You can also navigate through the internet by using non-secure Wi-Fi as it provides you safe and protected navigation. This wonderful web browser has the capability to save your bandwidth on regular web browsing. It works as virtual theme pad or virtual game pad web browser which enables you to get unlimited streaming. It also includes an incognito tab which helps in clearing all your browsing history to your device so that the working process of your handset would be easily increased. Colored toolbar and sidebars enable you to make easy accessing through this amazing web browser.

<a href="https://contentcomandroidbrowserhome.co//" target="_blank">content://com.android.browser.home/</a>

<
  • 0 Comments
  • 0 Articles
10 September 2017 15:23

Santosh

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Puffin Browser: Puffin browser includes very fast mobile web browser which enables you to save your protected data in the cloud. You can also navigate through the internet by using non-secure Wi-Fi as it provides you safe and protected navigation. This wonderful web browser has the capability to save your bandwidth on regular web browsing. It works as virtual theme pad or virtual game pad web browser which enables you to get unlimited streaming. It also includes an incognito tab which helps in clearing all your browsing history to your device so that the working process of your handset would be easily increased. Colored toolbar and sidebars enable you to make easy accessing through this amazing web browser.

content://com.android.browser.home/

We share how to guides for our readers to solve their daily technology related problems. Technology & Internet world is evolving continuously and in this changing world most of the users are not tech-savvy. So, we try to provide step by step tutorials for such people so that they don’t get left behind by others.
web magazine

<
  • 0 Comments
  • 0 Articles
10 September 2017 15:24

web magazine

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
We share how to guides for our readers to solve their daily technology related problems. Technology & Internet world is evolving continuously and in this changing world most of the users are not tech-savvy. So, we try to provide step by step tutorials for such people so that they don’t get left behind by others.
web magazine

<
  • 0 Comments
  • 0 Articles
11 September 2017 18:31

ttf236 ttf236

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
http://www.avisrentaman.com/
http://www.baileys-taxis.com/
http://www.butterflyspraytanning.com/
http://www.chrissyscosmetics.com/

<
  • 0 Comments
  • 0 Articles
13 September 2017 05:36

geometry dash full version free online

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Geometry dash 2.1 apk hyphen dodge all the challenges that seem in your way and runs on the simple game in which the display to press for the character to proceed..For those that donot have this game, then talk about what truly worth. Geometry Dashboard 2.1 apk is now accessible for all mobile platforms and even additionally to the computer. While players aren’t demanded to perform a degree to progress to the following problem increases mostly.
geometry dash full version free online

<
  • 0 Comments
  • 0 Articles
24 September 2017 07:37

wpa tester

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Download your preferred APK file version from above links.
Locate to Download Manager and open the installer APK package.
In case security blocks the installation go to Settings -> Device Management -> Tick “Unknown Sources”.
Restart the installation process and complete it.
You’re all set! You can now use the app.
wpa tester

<
  • 0 Comments
  • 0 Articles
27 September 2017 12:40

emoji meanings in snapchat

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
The Grimace Face Emoji tells that, the friend for whom you send the snaps mostly is the friend,who also send the snaps mostly.For exmaple if You send the most number of snaps to your friend, making him your best friend. But some other friend from your friend’s list has also been sending the most number of snaps to your friend, making him his best friend as well.Hope u understand.
emoji meanings in snapchat

<
  • 0 Comments
  • 0 Articles
28 September 2017 02:18

kekini

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Thanks for such a great post and the review....

Everglades National Park, Florida

I really appreciate the research you put into it.

Be Comfortable

<
  • 0 Comments
  • 0 Articles
1 October 2017 08:40

tutuapp android

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Easy to Find Pokemon’s: In normal Pokemon go apk, finding Pokemon is a bit hard task because you need to walk through to catch the picabhoos. Tutuapp Pokemon go apk will help you to find neighborhood Pokemon’s easily without walking.
tutuapp android

<
  • 0 Comments
  • 0 Articles
30 October 2017 21:13

bohimia

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Best Sites To Download Paid Android Games For Free
This is very much a work in progress whenever I find out about one who is more beautiful than any of these I will add her and kick out number ten Thanks for sharing the informative post.

<
  • 0 Comments
  • 0 Articles
6 November 2017 14:09

阿方

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Qingdao Funuoda Packing Co., Ltd. is a professional manufacturer specialized in designing,

manufacturing, marketing and service of flexible plastic packaging. We are located in Qingdao,

Shangdong Province, a beautiful coastal city in eastern China, and covers an area of 6000 square

meters. Our main products are Food packaging bags, coffee and tea packaging bags,liquid and spouted

pouches, health food packaging bags,pet food packaging bags. applying in Food and beverage industry,

pet food industry, detergent industry.
http://www.funuodapacking.com/

<
  • 1 Comment
  • 0 Articles
16 November 2017 19:50

oakjkg3

Reply
  • Group: Members
  • РRegistered date: 16.11.2017
  • Status: Currently Offline
 
merica: 10%
8.Our service
Besides our existing molded products, our company also can produce solar panel according to the drawings or samples from our customers. We control the product quality critically for every step during the manufacturing and the transportation. Technical support is provided that is second to none. The after-sales service is excellent and considerate too. 265w solar panel
website:http://www.pvsolare.com/

Our service
If you have any questions in Crystal Rhinestones can consult us, we will contact you in the first time to negotiate.
Wing Loose Rhinestones online
website:http://www.pxcrystalrhinestone.com/

Our service
If you have any questions in Crystal Rhinestones can consult us, we will contact you in the first time to negotiate.
Wing Loose Rhinestones online
website:http://www.pxcrystalrhinestone.com/

A4: Sure, warmly welcome.
Q5: What is the payment?
A5: T/T, L/C at sight, Alipay,Western&Union,Paypal,etc.Plastic Sport Water Bottle manufacturers
website:http://www.px-plastic.com/
website2:http://www.pengxin-plastic.com/

Wuxi Puxin Machinery Factory
Mob: 13951579100
Tel: 86-510-83208381
Fax: 86-510-83209882
Add: 76# Qianluo Load, Huishan District,Wuxi,Jiangsu,China
Email: [email protected]
Website: http://www.Pxslitter.comslitter price
website:http://www.pxslitter.com/slitting-series/

Our service
We offer free sample service. Arrange production, perform product testing, guarantee the products’quality, charter and book shipping space, ensure delivery on time. Ball Shaped Type Bentonite Cat Litter manufacturers
website:http://www.pyemily.com/
website2:http://www.py-emily.com/

As all we know, Chongqing, which surrounded by the Yangtze rive, is famous for motorcycles, autos, motorcycle parts and auto parts manufacturing. Our factory Located in the economic center of Chongqing, there are convenient transportation (15km from the port chongqing, 20km from the airport and 10km from the railway station).
Paize follows the step of government about “ china dream”, “ the belt and road”, we are doing our best to supply customers satisfied products and excellent service.Customized Motorcycle speedometer For HONDA CG125
website:http://www.pzmotoparts.com/

Value: Trust and Win-win.
Mission: Build the image of "Made in China".
Vision: Let our products spread all over the world.wholesale ptfe tube
website:http://www.qcssproducts.com/
website2:http://www.qcssfitting.co

Tempered glass production line
Now our company is supplying high quality glass to more than 50 countries on 5 continents.Low Iron Mistlite Pattern Glass suppliers
website:http://www.qdbrilliantglass.com/

<
  • 1 Comment
  • 0 Articles
21 November 2017 14:35

qqs233

Reply
  • Group: Members
  • РRegistered date: 21.11.2017
  • Status: Currently Offline
 
Contact us:
Jiangsu Titan New Energy Technology Development Co.,Ltd
Add:NO.211 Renmin West Road ,Hudai Industrial Park, Wuxi City ,Jiangsu Province ,China
Tel:86-510-85588898
Fax:86-510-85589698
Mobile:+86 181 6885 4031
Skype:181 6885 4031
Whatsapp:181 6885 4031
Email: [email protected]
Web: www.titanwindturbine.comChina Vertical Shaft Wind Driven Generator manufacturers
website:http://www.titanwindturbine.com/wind-driven-generator/vertical-shaft-win
d-driven-generator/

Stainless steel dirty clothes bag trolley with best quality from Kangli
The main body is made of high quality stainless steel pipe.
The dirt bag is made of high quality Oxford waterproof cloth and can be removed and cleaned.
Four four inch package, mute casters, feet with brake.
Colors are customized according to user requirements
SIZE: 800*500*900mmChina Baby Carriage factory
website:http://www.tjkanglimedical.com/trolley/baby-carriage/

TKflor is a professional bus floor manufacturers and suppliers in China with great no slip flooring projects and hot sales on going, welcome to buy customized products from our factory and check prices with us.
Dense concentration of deep inlaid anti slip particles throughout the wear layer =>; Permanent slip performance R10

No carborundum =>; easier to handle& cut
Mineral crystal particules and new colours =>; Fresher colour palette
100% recyclable

229-635229-654

229-663229-686

229-642229-652

229-674229-681

229-688safety flooring supplies projects
website:http://www.tkfloor.net/safety-flooring/

<
  • 0 Comments
  • 0 Articles
22 November 2017 18:37

zlzl21c

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Address: Room 813, Bao Yi Long Ji Center,No.136 Xi'an Economy & Technology Development Area, Xi'an, China
Post Code: 710018
Tel : +86(0)29-8433 5318
Fax: +86(0)29-8433 5319
E-mail: [email protected] Http: www.balancefrp.comhigh quality permeat port
website:http://www.balancefrp.com/
website2:http://www.balancefrpvessel.com/

<
  • 0 Comments
  • 0 Articles
29 November 2017 07:06

mickel

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Ohh wow. This a one amazing information. I must say this blog post is one of the most informative post up till now. You should post it on type my paper for me. so many people can read it.

<
  • 0 Comments
  • 0 Articles
29 November 2017 07:08

Mildred

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
I have been searching allover but I can't find essay service online such as yours. I hope you guys resolve your matters soon and get back to work with the same zeal.

<
  • 0 Comments
  • 0 Articles
4 December 2017 05:35

RIS

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
As you’ve learned AOL sign up above, now let’s see how you can do AOL Sign in.

First of all, visit www.aolmail.com
You’ll be taken to a page where you’ve to enter your registered email address and the password.
After entering the password, click on Sign in. You’ll be signed into AOL mail!

<
  • 0 Comments
  • 0 Articles
10 December 2017 19:17

Escorts in Kolkata

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Beauti Queen amazing kolkata escorts agency alwyas ready for you at your doorstep. Beauti Queen provide you high profile independent girl in kolkata, escorts service in kolkata, kolkata escorts. If you are looking for the ultimate encounter in Kolkata then I am your sophisticated young Kolkata escorts that provides upscale companionship for making your night becomes true.
escorts service in kolkata, kolkata escorts, escorts in kolkata, independent escorts in kolkata, female escorts in kolkata

<
  • 0 Comments
  • 0 Articles
12 December 2017 23:53

Lucky Patcher

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
<
  • 0 Comments
  • 0 Articles
16 December 2017 06:47

jerny

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
<
  • 0 Comments
  • 0 Articles
17 December 2017 04:47

martin

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
this is the most awesome app for patching your ads on your mobile.
EaseUS Partition Master License Key

<
  • 0 Comments
  • 0 Articles
18 December 2017 06:11

shahed

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
wow. This one amazing information.
Omnisphere Crack

<
  • 0 Comments
  • 0 Articles
18 December 2017 20:01

amazing koli

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Previous Next
Information
Comment on the news site is possible only within (days) days from the date of publication.