0

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

7
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by chintan@dani
0

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

0

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;
}
?>

Edited by Ezzaral: Snipped &quot;fake sig&quot; link. Please restrict such links to your site-wide user signature, which can be edited from the user control panel.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.