- 정보공유
[그누보드팁] 랜덤 아이디 문자열 생성
function get_create_mb_id($length) {
$characters = '0123456789';
$characters .= 'abcdefghijklmnopqrstuvwxyz';
$characters .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$string_generated = '';
$nmr_loops = $length;
while ($nmr_loops--) {
$string_generated .= $characters[mt_rand(0, strlen($characters) - 1)];
}
return $string_generated;
}
$j = 0;
do {
$mb_id = get_create_mb_id(10);
$sql3 = " select count(*) as cnt from {$g5['member_table']} where mb_id = '".$mb_id."' ";
$row3 = sql_fetch($sql3);
if(!$row3['cnt'])
break;
else {
if($j > 20)
die('Member ID Error');
}
} while(1);
echo $mb_id;