我正在尝试使用会话中的信息来查询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);
?>
有人能看出为什么这段代码无效吗?
答案 0 :(得分:0)
确保获得以下值:
$ newpassword = $ _POST [&#34; newpassword&#34;];
请在此声明后使用exit调试它。 希望这有帮助。