Hi all i need to generate a 10 digit (at least) alphanumeric id when a customer submits a form, it has to be unique.

Is there an easy way of doing this or do i just use the uniqid function and then check against the database that it doesnt already exist

Regards

Hi,

If you're storing the id in a database, why not use an auto-increment ID field?

R.

Try doing this:

uniqid(mt_rand(), true);

Thankyou for all the great suggestions their all perfect for what i want

Hello Dendixon

Here is the code as per you requirement.
It is more than 10 digit but you can configure the loop..

<?php
for ($i=0; $i<7; $i++) {
    $d=rand(1,30)%2;
//    echo $d ? chr(rand(65,90)) : chr(rand(48,55)).rand(01,99).$d;
	$w=$d ? chr(rand(65,90)) : chr(rand(48,55)).rand(01,99).$d;
	echo $w;
}
?>
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.