我有一个带有先前代码和函数的html / php页面changepassword()
但是有一个函数会提示用户在密码过期时更改密码。
我希望当用户点击更改密码按钮时,它会调用change password
功能(所有代码都位于同一页面上)。我遇到的问题是,当用户点击action="index.php"
按钮时,它会默认返回登录屏幕。我猜测它是action="index.php"
属性的结果。
如何让按钮直接调用该函数而不执行$oldpassword = $_POST["oldpassword"];
$newpassword = $_POST["newpassword"];
$confirmpassword = $_POST["confirmpassword"];
$passwordResult = '';
if($_POST["update"] == "user")
{
$passwordResult = ChangePassword($db_connection, $userid, $_POST["oldpassword"], $_POST["newpassword"], $_POST["confirmpassword"]);
}
echo'
<div class="dataform">
<form method="post" action="index.php">
<table>
<tr><td>
Old Password:
</td><td>
<input type="password" name="oldpassword" value=""/><br/>
</td></tr><tr><td>
New Password:
</td><td>
<input type="password" name="newpassword" value=""/><br/>
</td></tr><tr><td>
Confirm Password:
</td><td>
<input type="password" name="confirmpassword" value=""/><br/>
</td></tr><tr><td>
<input type="submit" value="Change Password"/>
</td></tr>
</table>
<input type="hidden" name="update" value="user"/>
</form>
'.$passwordResult.'
</div>';
}
,它将始终默认返回登录页面?
这是代码的突触
function ChangePassword($db_connection, $userid, $old, $new, $confirm)
{
if($confirm != $new)
{
echo '<font color="red">The confirmation password does not match the new password.</font>';
return;
}
$qrystring = 'UPDATE user
SET password = SHA1(?)
WHERE userid = ?
AND password = SHA1(?)';
if ($statement = $db_connection->prepare($qrystring))
{
$statement->bind_param('sss', $new, $userid, $old);
$statement->execute();
$reportid = $db_connection->insert_id;
if($statement->affected_rows != 0)
{
$db_connection->commit();
echo $header_string.'
<font color="green"><b>Your password was successfully updated.</b></font><br/>';
}
else
{
$db_connection->rollback();
echo $header_string.'
<font color="red">We were unable to update your password. Please verify that the old password is correct.<i>(u3)</i></font><br/>';
}
$statement->close();
}
else
{
$db_connection->rollback();
echo $header_string.'
<font color="red">We were unable to update your password at this time.<i>(u4)</i></font><br/>';
}
}
更改密码功能:
cordova-plugin-whitelist