Sometimes we need to add users in batches, as long as the php is put into the UCenter directory, it can be executed. The code is as follows:
// Author: 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 ');
?>
Global $ _ SGLOBAL; // defines global variables.
// Registered user name
$ Rando_first_name = array (
'Where to shop ',
'Same as the poor BBS ',
'Taizhou Mame ',
'1970 hackers'
);
// Registered password
$ Rando_first_password = array (
'15032x ',
'123 ',
'123 ',
'1ggg17'
);
/* To ensure that the user name and password can match the upper number, the array length of the output characters is compared.
Echo count ($ rando_first_name );
Echo "______";
Echo count ($ rando_first_password );
Exit;
*/
For ($ I = 0; $ I
$ Username = $ rando_first_name [$ I];
$ Pwd1 = $ rando_first_password [$ I];
$ Salt = substr (uniqid (rand (),-6 );
$ Pwd = md5 (md5 ($ pwd1). $ salt );
// Query whether the user name already exists
$ SQL _username = "select username from uc_members where username = '". $ username ."'";
$ S_name = $ _ SGLOBAL ['DB']-> fetch_array ($ _ SGLOBAL ['DB']-> query ($ SQL _username ));
// If the user with the same name does not exist
If ($ username! = $ S_name ['username']) {// if it does not exist
$ _ 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
";
} Else {
Echo "the user you want to add has been added! ";
}
}
// Author: www.tongqiong.com
?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service