Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Refference number using PHP


ghost's Avatar
0 0

Heya sorry to bother everyone again. How would I make a unique refference number in PHP?


ghost's Avatar
0 0

Cheers. I did have a look at that. But i didnt know if anyone knew a better way of doing it.

Ty though :)


yours31f's Avatar
Retired
10 0

I would probably say that going with the uniqueID and random are the choices I would go with, But don't quote me, I've only been doing php for about 4 days now.


spyware's Avatar
Banned
0 0

**yours31f wrote:**I've only been doing php for about 4 days now.

Lies.

Ssssh, just, shut it. Lies. You know it.


ghost's Avatar
0 0

hahah ty yours31f and lol


yours31f's Avatar
Retired
10 0

Actually your right spyware, its only been three days.


Parker's Avatar
Ph4n70m
0 0

You're*


spyware's Avatar
Banned
0 0

Parker wrote: You're*

It's*


yours31f's Avatar
Retired
10 0

spyware wrote: [quote]Parker wrote: You're*

It's*[/quote]

wow, nice come back spy, run out of jokes for the day?


spyware's Avatar
Banned
0 0

yours31f wrote: wow, nice come back spy, run out of jokes for the day?

Nope, don't worry one bit :+.


ghost's Avatar
0 0

DarkMantis wrote: How would I make a unique refference number in PHP? Explain what you mean by "unique reference number", and we'll know which "right" answer to give you.

yours31f wrote: wow, nice come back spy, run out of jokes for the day? Of course not… every one of your posts is a joke. Almost a crime to humanity.


ghost's Avatar
0 0

I mean something like on a form after you fill it out it gives you a refference number incase you need to contact them and they can reffer it to the reference number that you give them. If you know what i mean?


ghost's Avatar
0 0

DarkMantis wrote: I mean something like on a form after you fill it out it gives you a refference number incase you need to contact them and they can reffer it to the reference number that you give them. If you know what i mean?

Yeah, you could use rand(). I would say to make a random string generator function and then md5 the random string you gave them, store it in a database and output it. That way you are pretty sure it is unique since you can check if it is already in the db. (even though this isn't a number)


ghost's Avatar
0 0

That sounds like a promising idea. Yeah it doesnt necessarily need to be a 'number' just needs to be a unique string.

Thanks guys =]


yours31f's Avatar
Retired
10 0

from what i have seen in the past the number is random then db tested, and then sent in an e-mail so the user can keep the number, that way if they clear their data they still have it.


ghost's Avatar
0 0

DarkMantis wrote: I mean something like on a form after you fill it out it gives you a refference number incase you need to contact them and they can reffer it to the reference number that you give them. If you know what i mean?

Ahh, okay. Instead of just generating a random item with rand or uniqid, why not just use unique aspects of the form itself to MD5 and give (truncated to a length of your choice, of course) as a reference code? Examples of this could be the username, a person's mailing address, or even a person's last name and birthdate. As everyone else has already stated, you'd need to store the ref number in the db in order for it to be referenced later.


ghost's Avatar
0 0

If the information is going to be stored in the database why not have a unique table index? That would actually speed-up look up of the form and guarantee uniqueness - whereas random strings and integers do not.

Just have a column - in the row where you store the information - represent the row index. Set it to auto increment and be the primary key for the table.