Home > php教程 > php手册 > body text

php生成会员账号

WBOY
Release: 2016-06-16 09:16:22
Original
1202 people have browsed it

自己用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);
}
Copy after login

您可能感兴趣的文章

  • php生成柱状图(统计图)程序
  • 在php中分别使用curl的post提交数据的方法和get获取网页数据的方法总结
  • php生成短网址的思路以及实现方法
  • php生成动态验证码图片(gif)
  • PHP 生成连续的数字(字母)数组函数range()分析,PHP抽奖程序函数
  • php生成二维码的方法总结
  • PHP生成随机数的几种方法
  • php生成验证码函数
Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template