Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Generate Referance Number
Old 02-14-2008, 06:53 PM Generate Referance Number
vkw91's Avatar
Ultra Talker

Latest Blog Post:
Good Web Design Guide - part 1
Posts: 314
Name: Vicky
Location: Wales
Trades: 0
Hi Guys, just a quick question,

What would be the best way to auto generate a referance number on a contact form which is send to both the owner and customer?

Thanks in advance!
__________________
Blog (new):
Please login or register to view this content. Registration is FREE

Portfolio:
Please login or register to view this content. Registration is FREE

Techno Pup:
Please login or register to view this content. Registration is FREE

vkw91 is offline
Reply With Quote
View Public Profile Visit vkw91's homepage!
 
 
Register now for full access!
Old 02-14-2008, 07:57 PM Re: Generate Referance Number
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
What do you mean by reference number? If you mean what I think you mean then you should try a hash. md5 or sha1

Last edited by NullPointer; 02-14-2008 at 07:58 PM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 02-14-2008, 08:02 PM Re: Generate Referance Number
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
anything you could use to track the contact ?
Like, ddmmyyyy-numeric, or something even totally random, like
http://www.php.net/manual/en/function.uniqid.php
PHP Code:
md5(uniqid(rand(), true)); 
</span></span>
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 02-14-2008, 08:29 PM Re: Generate Referance Number
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
What is the likelyhood of a collision with uniqueid()? I was thinking just an md5 hash of some of the user's info that is likely to be unique to them:
PHP Code:
$reference md5($lastName $firstName time()); 
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 02-14-2008, 08:51 PM Re: Generate Referance Number
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Well, uniquId creates an hash based on the epoch time, so the likelyhood is fairly low.
I believe in the order of the micro second. And the rand() with the md5 makes the rest.

As always, there is never enough entropy, and a real random number is almost impossible, but I consider this as a good enough result for what I usually want to do.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to Generate Referance Number
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30765 seconds with 12 queries