当前位置: 萬仟网 > IT编程>开发>PHP > UCenter 批量添加用户的php代码

UCenter 批量添加用户的php代码

2019年04月15日 23:24  | 萬仟网IT编程  | 我要评论
复制代码 代码如下:

<?
//作者:www.tongqiong.com
//header("content-type:text/html; charset=utf-8");
//include_once("include/config.php");
//include_once("include/db_mysql.inc.php");
////include_once("include/n_public_function.php");
//$db = new db_mysql("localhost","dbh218710","root","123");
include_once('./common.php');
include_once(s_root.'./data/data_magic.php');
?>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<?
global $_sglobal;//定义全局变量
//注册的用户名
$rando_first_name = array(
'哪里购物',
'同穷论坛',
'台州妈妈',
'7788黑客'
);
//注册的密码
$rando_first_password = array(
'15032x',
'103716',
'114517',
'1ggg17'
);
/*为了确保用户名和密码能对上号,输出个字的数组长度进行比较
echo count($rando_first_name);
echo "______";
echo count($rando_first_password);
exit;
*/
for($i=0;$i<count($rando_first_name);$i++){
$username = $rando_first_name[$i];
$pwd1 = $rando_first_password[$i];
$salt = substr(uniqid(rand()), -6);
$pwd = md5(md5($pwd1).$salt);
//查询是否已存在此用户名
$sql_username = "select username from uc_members where username='".$username."'";
$s_name = $_sglobal['db']->fetch_array($_sglobal['db']->query($sql_username));
//如果不存在重名的用户
if($username != $s_name['username']){//如果不存在
$_sglobal['db']->query("insert into uc_members (username, password,regdate,salt)
values ('$username', '$pwd','".mktime()."','$salt')");
$sql = "select uid from uc_members where username='".$username."'";
$_sglobal['db']->query($sql);
$uuu = $_sglobal['db']->fetch_array($_sglobal['db']->query($sql));
echo $uuu['uid'];
$_sglobal['db']->query("insert into uc_memberfields (uid)
values ('".$uuu['uid']."')");
echo $username."success<br/>";
}else{
echo "您要添加的用户已添加!";
}
}
//作者:www.tongqiong.com
?>
</body>
</html>

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

◎已有 0 人评论

Copyright © 2019  萬仟网 保留所有权利. 粤ICP备17035492号-1
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com