改密碼,該如何解決

來源:互聯網
上載者:User
改密碼
我資料庫裡面有3000個使用者,我初始將每個使用者的使用者名稱和密碼都設為一樣的了,現在我要改每個使用者的密碼(密碼是自動產生含數字、字母、符號、密碼為8位元),如果一個一個的改太麻煩了,請問那位能不能幫忙寫個好點的程式一下將所有的密碼改玩

------解決方案--------------------
include("dbConn.class.php");//串連資料庫
$dbConn=new dbConn;
$str = 'ABCDEFGHIJKMNPQRSTUVWXYZ1234567890abcdefghijkmnpqrstuvwxyz'; //密碼組成的欄位
$l = strlen($str);
$sql="select * from users";//查詢出結果集
$result=$dbConn->conn($sql);
$array=mysql_fetch_array($result);
while($array=mysql_fetch_array($result["rs"])){//用while迴圈結果集
$str_pwd="";
for($i=1;$i<=8;$i++){//迴圈8次得到密碼
$num=rand(0,$l-1);
$str_pwd.= $str[$num];
}
$sql="update users set password='$str_pwd' where username='".$array["username"]."'";//修改密碼的SQL
$dbConn->conn($sql);//執行SQL語句
}
?>
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.