UCenter 批量添加用戶的php代碼
更新時間:2012年07月17日 10:57:48 作者:
有時候我們需要批量添加用戶,只要把該php放進(jìn)UCenter目錄下,執(zhí)行就可以了。
復(fù)制代碼 代碼如下:
<?
//作者: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'
);
/*為了確保用戶名和密碼能對上號,輸出個字的數(shù)組長度進(jìn)行比較
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>
您可能感興趣的文章:
相關(guān)文章
PHPMYADMIN導(dǎo)入數(shù)據(jù)最大為2M的解決方法
PHPMYADMIN還原數(shù)據(jù)庫的時候上傳的最大限制:2,048 KB,數(shù)據(jù)庫稍微大一些就無法處理,要么使用其他的備份還原工具如帝國備份王,要么就分卷導(dǎo)出,那么有沒有辦法還使用PHPMYADMIN來處理呢2012-04-04
PHP多線程批量采集下載美女圖片的實(shí)現(xiàn)代碼(續(xù))
之前寫過一篇《PHP批量采集下載美女圖片》文中主要采用file_get_content做采集圖片,今天發(fā)現(xiàn)采集了400張圖片 居然需要70分鐘以上,真是難以忍受2013-06-06
Bootstrap+PHP實(shí)現(xiàn)多圖上傳功能實(shí)例詳解
這篇文章主要介紹了Bootstrap+PHP實(shí)現(xiàn)多圖上傳功能實(shí)例詳解,本文圖片加實(shí)例相結(jié)合的形式給大家介紹的非常詳細(xì),需要的朋友可以參考下2018-04-04
徹底刪除thinkphp3.1案例blog標(biāo)簽的方法
這篇文章主要介紹了徹底刪除thinkphp3.1案例blog標(biāo)簽的方法,以thinkphp3.1框架中的案例blog為基礎(chǔ)介紹了刪除日記時同步刪除tag冗余數(shù)據(jù)的方法,非常具有實(shí)用價值,需要的朋友可以參考下2014-12-12
laravel自定義分頁的實(shí)現(xiàn)案例offset()和limit()
今天小編就為大家分享一篇laravel自定義分頁的實(shí)現(xiàn)案例offset()和limit(),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-10-10
TP5(thinkPHP5框架)實(shí)現(xiàn)顯示錯誤信息及行號功能的方法
這篇文章主要介紹了TP5(thinkPHP5框架)實(shí)現(xiàn)顯示錯誤信息及行號功能的方法,結(jié)合實(shí)例形式分析了thinkPHP5顯示錯誤信息及行號的相關(guān)配置文件與設(shè)置修改方法,需要的朋友可以參考下2019-06-06

