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



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


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..

for ($i=0; $i<7; $i++) {
//    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;