since this is a registration and DB is involve, just use the primary key of your table and append it with "CUS" ________________________________ From: Alimuddin Sidiqui <alimuddin_rewa@xxxxxxxxx> To: php-objects@xxxxxxxxxxxxxxx Sent: Tue, December 29, 2009 2:15:27 PM Subject: Re: generat unique id in php Hello user this function <? echo random_string( 6) ?> function random_string( $length) { // if you want extended ascii, then add the characters to the array $characters = array('0','1' ,'2','3', '4','5',' 6','7','8' ,'9','A', 'B','C',' D','E','F' ,'G','H', 'I','J',' K','L','M' ,'N','O', 'P','Q',' R','S','T' ,'U','V', 'W','X',' Y','Z'); $random_str = ""; for ($i = 0; $i < $length; $i++) { srand((double) microtime( )*1000000) ; $random_chr = round(rand(0, count($characters) -1)); $random_str .= $characters[ $random_chr] ; } return ($random_str) ; } --- On Fri, 25/12/09, rahul dongre <mady_dongre@ yahoo.co. in> wrote: From: rahul dongre <mady_dongre@ yahoo.co. in> Subject: generat unique id in php To: "php" <php-objects@ yahoogroups. com> Date: Friday, 25 December, 2009, 8:42 AM hello all i want to generate a unique code for each customer that are going to register on my site. and each customer is identify by this unique code. plz suggest me how i generate unique code like this "CUS-123" The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo. com/ [Non-text portions of this message have been removed] The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo. com/ [Non-text portions of this message have been removed] [Non-text portions of this message have been removed]