generate a Serial Number

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

generate a Serial Number

Post by madhu »

Hi all,

Is there any way to generate a Serial Number whenever we execute a php file???

Actually am trying to generate a "transaction id" for implementing payment gateway while registering to a site.

The transaction id shouldbe in this format. WYYYYMMDDXXXXSLN

where W-consatnt , YYYY-Year , MM-Month , DD-day , XXXX -Constant , and the final one SLN is the serial number.

Now i want to generate a serial number for every subscriber.

Eg: for 20061208 (W20061208XXXX001,W20061208XXXX002,W20061208XXXX003,W20061208XXXX004,..........)
for 20061209 (W20061209XXXX001,W20061209XXXX002,W20061209XXXX003,W20061209XXXX004,..........)

Can any body tell, is there any function to generate that SLN(Serial number)???

Waiting for your valuable replies.....

Thanks and regards
MADHU
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

You need to store the serial numbers somewhere if you don't want to repeat.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

I'd first consider how insecure that system is, and possibly add a change or two so they aren't so easy to guess.

Then, you could simply make your own function for this. There is random number generators & string manipulation functions, but for your own custom format, there isn't exactly always a solution that fits your need the way you want.
Post Reply