<?php
include "../inc/chec.php";
?>
<script src="../js/admin_js.js"></script>
<link href="../css/style.css" rel="stylesheet">
<table width="765" height="450" border="0" cellpadding="0" cellspacing="0" style="border: 1px solid #9CBED6; margin-top:15px;">
<tr><td align="center" valign="middle">
<form name="mod_pwd" id="mod_pwd" method="post" action="modify_pwd_chk.php">
<table width="300" height="116" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="126" align="right" valign="middle">旧密码:</td>
<th width="174" align="left" valign="middle"><input name="old_pwd" type="password" id="old_pwd" size="15"></th>
</tr>
<tr>
<td align="right" valign="middle">新密码:</td>
<td align="left" valign="middle"><input name="new_pwd" type="password" id="new_pwd" size="15"></td>
</tr>
<tr>
<td align="right" valign="middle">确认密码:</td>
<td align="left" valign="middle"><input name="two_pwd" type="password" id="two_pwd" size="15"></td>
</tr>
<tr>
<td colspan="2" align="center" valign="middle"><input type="submit" nanme="submit" value="修改" onclick="return mod_chk();"></td>
</tr>
</table>
</form>
</td></tr></table>
modify_pwd_chk.php代码:
<?php
session_start();
include "../inc/chec.php";
include "../conn/conn.php";
$sqlstr = "select * from tb_controller where id = ".$_SESSION[id]." and mana_pwd = '".$_POST[old_pwd]."'";
$result = mysql_query($sqlstr,$conn);
if($rows = mysql_fetch_row($result)){
$modsql = "update tb_controller set mana_pwd = '".$_POST[new_pwd]."' where id = ".$_SESSION[id];
if(mysql_query($modsql,$conn))
echo "<script>alert('密码修改成功');history.go(-1);</script>";
else
echo "<script>alert('密码修改失败');history.go(-1);</script>";
}
else{
echo "<script>alert('密码错误,请重新输入!');history.go(-1);</script>";
}
?>
admin_js.js代码:
//修改管理员密码
function mod_chk(){
var dmp = document.mod_pwd;
if(dmp.old_pwd.value == "" || dmp.new_pwd.value == "" || dmp.two_pwd.value == ""){
alert("密码框不允许为空");
return false;
}
if(dmp.new_pwd.value != dmp.two_pwd.value){
alert("两次密码不一致");
return false;
}
}