How to change the password-php Tutorial

Source: Internet
Author: User
I changed the password to 3000 users in my database. I initially set the username and password of each user to the same, now I want to change the password of each user (the password is automatically generated with 8 digits including digits, letters, symbols, and passwords). If one change is too troublesome, could you help me write a better program and change all the passwords? Solution: -------------------- & lt ;? Phpinclude (& quot; dbConn. c change password
There are 3000 users in my database. I initially set the usernames and passwords of each user to the same, now I want to change the password of each user (the password is automatically generated with 8 digits including digits, letters, symbols, and passwords). If one change is too troublesome, could you help me write a better program and change all the passwords?

------ Solution --------------------
Include ("dbConn. class. php"); // connect to the database
$ DbConn = new dbConn;
$ Str = 'abcdefghijkmnpqrstuvwxyz1234567890abcdefghijkmnpqrstuvwxyz '; // password composition field
$ L = strlen ($ str );
$ SQL = "select * from users"; // query the result set.
$ Result = $ dbConn-> conn ($ SQL );
$ Array = mysql_fetch_array ($ result );
While ($ array = mysql_fetch_array ($ result ["rs"]) {// use the while loop result set
$ Str_pwd = "";
For ($ I = 1; $ I <= 8; $ I ++) {// obtain the password eight times in a loop
$ Num = rand (0 L-1 );
$ Str_pwd. = $ str [$ num];
}
$ SQL = "update users set password = '$ str_pwd' where username = '". $ array ["username"]. "'"; // SQL statement used to change the password
$ DbConn-> conn ($ SQL); // execute an SQL statement
}
?>

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.