RE: Serial Numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Gary [mailto:gpaul@xxxxxxxxxxxxxxxx] 
> Sent: Monday, July 12, 2010 11:53 AM
> 
> I'm sure it is possible, but I am unsure how to do this.  I 
> have created a 
> Sale coupon that I was going to put up on a site that I 
> manage, for visitors 
> to print out and bring to the store. The coupon is currently 
> a .png, however 
> I was planning on converting to a pdf.  I would like to put 
> on the coupon a 
> serial number that increases by 1 everytime the page is 
> viewed. I dont 
> really care if someone refreshes the page and skews the numbers.
> 
> Is this possible and could someone give me some help?

Is there a reason you need to increment by 1? I mean, are you going to
validate the coupon someone brings in to see if it's in the database or is
used already? Since you say you don't care if the number is skewed, it
sounds as if you don't care about the code either really.

Point being, why not just use md5(time()) or uniqid() or something and make
some truly unique code (that you may or may not wish to store in a DB).
This will be obscure enough the average person won't know that it isn't
tracked and most likely won't try to make their own. If I saw 123457, I'm
pretty sure I could make a coupon with 123500 on it. But if I saw
6ccd780c-baba-1026-9564-0040f4311e29 then I'm not really going to try and
fudge one of those. Then I'd use the barcode library to print the code
(again, doesn't have to actually work if you're not going to do a lookup)
just to add more "realizm" to it. There are a billion different ways to
make a unique ID. Even IF you are going to track them, you really shouldn't
do a sequential code as you originally wanted to do.

http://us.php.net/manual/en/function.uniqid.php
http://php.net/manual/en/function.com-create-guid.php
http://us.php.net/manual/en/function.mssql-guid-string.php
http://us.php.net/manual/en/function.md5.php
http://us.php.net/manual/en/function.sha1.php
http://us.php.net/manual/en/function.hash.php
http://us.php.net/manual/en/function.time.php
http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#functio
n_uuid

Heck, you could even just use ip2long() on their IP address and then when
someone "redeems" the coupon code, a simple long2ip() would tell you if
it's a valid "IP" format rather than some hacked up string.
http://us.php.net/manual/en/function.ip2long.php
http://us.php.net/manual/en/function.long2ip.php

Daevid.
http://daevid.com

"Some people, when confronted with a problem, think 'I know, I'll use
XML.'"
Now they have two problems. 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux