zoukankan      html  css  js  c++  java
  • UCenter 批量添加用户

    <?
    //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(
    		'zhangcan',
    	'zhengzhiwei',
    	'lvchenglei'
    
    	);
    
    
    	//注册的密码
    	$rando_first_password = array(
    		'15032x',
    	'103716',
    	'114517'
    		);
    
    
    
    /*为了确保用户名和密码能对上号,输出个字的数组长度进行比较
    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 "您要添加的用户已添加!";
    	}
    }
    
    
    ?>
    
    
    </body>
    </html>
    
  • 相关阅读:
    进制转换
    01背包基础
    6-14 Inspector s Dilemma uva12118(欧拉道路)
    9-4 Unidirectional TSP uva116 (DP)
    8-4 奖品的价值 uva11491(贪心)
    9-1 A Spy in the Metro uva1025 城市里的间谍 (DP)
    8-3 Bits Equalizer uva12545
    8-2 Party Games uva1610 (贪心)
    自动发邮件功能
    窗口截图.py
  • 原文地址:https://www.cnblogs.com/freespider/p/2268992.html
Copyright © 2011-2022 走看看