我正在尝试使用会话中的信息来查询MySQL数据库,以便更新用户密码。代码本身看起来应该可以根据我的判断运行,但是当我运行它时,数据库中的密码字段不会更改。以下是相关代码:

<?php
$accountname = $_SESSION[‘login’];
echo $accountname; //I am using this to make sure the session variable is working properly.  It does echo the text of the variable correctly.
$newpassword = $_POST["newpassword"];
$connection = mysqli_connect("I have the right information in here") or die(mysqli_error());

$updatepw = "UPDATE Login SET password = '$newpassword' WHERE account = '$accountname'";
mysqli_query($connection, $updatepw);
echo "<p>Your password has been updated.</p>";
mysqli_close($connection);
?>


谁能看到为什么此代码不起作用?

最佳答案

确保您在中获得了价值:


  $ newpassword = $ _POST [“ newpassword”];


请在此语句后使用exit对其进行调试。
希望对您有所帮助。

07-24 18:49