Hello,

Lets say I have a users Database.
When the user registers, it assigns a random id to the user using the mt_rand(); function.

What if there is a slight chance that there would be already the id of that user in the db. How can I prevent this from happening? Besides using AI in the db?

Thanks in advance! :)

Normally for a registration system you start at 0 and count up from that as each user is registered. So for example in the database you could have auto incremental or you could get php to fetch the highest number and add one to that. Hope that helps :)

Okay. Thanks, I think I will just start @ 0 then ;) THanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.