如何通过PHP脚本重置密码
<?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(); ?>
上一篇:PbootCMS输出分页代码 下一篇:如何实现网站迁移?(网站迁移的基本步骤)