Home  >  Article  >  php教程  >  php生成会员账号

php生成会员账号

WBOY
WBOYOriginal
2016-06-16 09:16:221161browse

自己用php写的生成会员账号功能,仅供参考,代码如下:

function get_number($table,$filed){
	if(!isset($table) || !isset($filed)){
		return '';
	}
	if(trim($table)=='' || trim($filed)==''){
		return '';
	}
	global $db;
	$user_number=str_shuffle(substr(randomname(-5),11));
	$sql="select `id` from `".$table."` where `".$filed."`='".$user_number."'";
	if($db->getRowsNum($sql) || strpos($user_number,'0')==0){
		get_number($table,$filed);
	}
	return $user_number;
}

/***********生成随机数[随机数是后五位,一共是19位]****************/
function randomname($start,$len=''){
	if(!isset($start) || !is_numeric($start) || ($len!='' && !is_numeric($len))){
		return '';
	}echo '-----';
	$seedstr=explode(' ',microtime(),5); 
	$seed=$seedstr[0]*10000; 
	$random=date('YmdHis', time()).rand(10000,100000);
	return $len===''?substr($random,$start):substr($random,$start,$len);
}

您可能感兴趣的文章

  • php生成柱状图(统计图)程序
  • 在php中分别使用curl的post提交数据的方法和get获取网页数据的方法总结
  • php生成短网址的思路以及实现方法
  • php生成动态验证码图片(gif)
  • PHP 生成连续的数字(字母)数组函数range()分析,PHP抽奖程序函数
  • php生成二维码的方法总结
  • PHP生成随机数的几种方法
  • php生成验证码函数
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn