<?php
$servername = "localhost";
$username = "your_username";
$password = "your_password";
$dbname = "your_database";
// 创建连接
$conn = new mysqli($servername, $username, $password, $dbname);
// 检测连接
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// 新密码
$new_password = "your_new_password";
$hashed_password = password_hash($new_password, PASSWORD_DEFAULT);
// 更新密码
$sql = "UPDATE users SET password = ? WHERE username = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ss", $hashed_password, $username);
$username = "your_admin_username"; // 替换成你的管理员用户名
$stmt->execute();
echo "Password reset successfully.";
$stmt->close();
$conn->close();
?>
标签:username,PHP,重置,stmt,密码,connect,new,password,conn From: https://www.cnblogs.com/hwrex/p/18376774