我正在尝试从登录的用户更改密码。在页面上它说密码已更改,但它没有更改,不在数据库上,也没有更改。我尝试使用新密码登录,但只有旧密码才能登录。我确实刷新了页面和所有内容。我尝试了几天,我想知道是否有人会发现我的错误。今晚我以为可能是因为密码在数据库上用md5加密。我将如何进行,因为我已经尝试了一些事情并且不起作用。
error_reporting(E_ALL); ini_set("display_errors","On");
<?php include "includes/connection.php" ?>
<?php
session_start();
if(@$_REQUEST["Submit"]=="Update")
{
$sql="update users set password ='$_REQUEST[newpassword]' where user='$_SESSION[myusername]'";
if (!mysql_query($sql)) die('err: PROBLEM IN QUERY: '.mysql_error());
header("Location:changpass.php?msg=updated");
}
else
die('err: PROBLEM IN REQUEST');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Change password</TITLE>
<script language="javascript" type="text/javascript">
function validate()
{
var formName=document.frm;
if(formName.newpassword.value == "")
{
document.getElementById("newpassword_label").innerHTML='Please Enter New Password';
formName.newpassword.focus();
return false;
}
else
{
document.getElementById("newpassword_label").innerHTML='';
}
if(formName.cpassword.value == "")
{
document.getElementById("cpassword_label").innerHTML='Enter ConfirmPassword';
formName.cpassword.focus();
return false;
}
else
{
document.getElementById("cpassword_label").innerHTML='';
}
if(formName.newpassword.value != formName.cpassword.value)
{
document.getElementById("cpassword_label").innerHTML='Passwords Missmatch';
formName.cpassword.focus()
return false;
}
else
{
document.getElementById("cpassword_label").innerHTML='';
}
}
</script>
<style type="text/css">
<!--
.style1 {font-weight: bold}
.style7 {
color: yellow;
font-size: 24px;
}
.style9 {
color: #FF6666;
font-weight: bold;
}
.style12 {
color: #666666;
font-weight: bold;
}
.style14 {color: #CC0033; font-weight: bold; }
-->
</style>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
</HEAD>
<BODY>
<form action="changpass.php" method="post" name="frm" id="frm" onSubmit="return validate();">
<table width="47%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" align="center"></td>
</tr>
<tr bgcolor="#666666">
<td colspan="2"><span class="style7">Change Password</span></td>
</tr>
<?php if(isset($_REQUEST['msg']) && $_REQUEST['msg'] == 'updated') { ?>
<tr bgcolor="#666666">
<td colspan="2"><span class="style7">Password has been changed successfully.</span></td>
</tr>
<?php } ?>
<tr>
<td bgcolor="#CCCCCC"><span class="style14">New Password:</span></td>
<td bgcolor="#CCCCCC"><input type="password" name="newpassword" id="newpassword" size="20" autocomplete="off"/> <label id="newpassword_label"
class="level_msg"></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><span class="style14">Confirm Password:</span></td>
<td bgcolor="#CCCCCC"><input type="password" name="cpassword" id="cpassword" size="20" autocomplete="off"> <label id="cpassword_label"
class="level_msg"></td>
</tr><tr bgcolor="#666666"><td colspan="2" align="center"><input type="submit" name="Submit" value="Update" /></td>
</tr></table><a href="index.php">Home</a></form></BODY></HTML>`