我在一个网站上工作,我必须在页面上重置密码脚本。为此,我使用 ajax 传递旧密码和新密码,并希望在同一页面上获得结果
我的重置页面代码是:-
<label>Enter current Password:</label><input id="cur_password" type="password" /><br/>
<label>Enter New Password:</label><input id="new_password" type="password" /><br/>
<label>Confirm New Password:</label><input id="confirm_password" type="password" /><br/>
<a id="Reset_pass" class="submitButtons" value="Submit">Submit</a>
我处理这个请求的java脚本页面是:-
$('#Reset_pass').click(function(){
var cur_password = $('#cur_password').val();
var new_password = $('#new_password').val();
var confirm_password = $('#confirm_password').val();
$('#current_password').parent().append("<img src=\"includes/ajaxLoader.gif\"");
$.ajax({
url: 'ajaxServer.php?request=Reset_password',
type: 'POST',
data: {'cur_password': cur_password,'new_password': new_password,'confirm_password': confirm_password},
dataType: "html",
success: function(result){
$('#current_password').parent().children('img').remove();
$('#current_password').parent().children('span.updateResults').remove();
$('#current_password').parent().append(result);
}
});
});
和 java 脚本将值传递给页面名称 ajaxServer 作为:-
if($request == "Reset_password")
{
$db_name = "user_mgmt";
include "connections/Con.php";//for database connection
$temp=$_SESSION['username'];
$result = mysql_query("select Password from register where Unique_id=$temp");
$row = mysql_fetch_array($result);
$status=strcmp('$_POST[cur_password]','$row[0]');
$confirm_pass=strcmp('$_POST[new_password]','$_POST[confirm_password]');
if(($status==0)&&($confirm_pass==0))
{
$query = mysql_query("UPDATE register SET Password='$_POST[new_password]' where Unique_id='$temp'");
}
?>
<span class="updateResults">
<?php
if($query){
echo "Your Password is reset";
}
else{
echo "Unable ";
}
?>
</span>
}
但是java脚本代码中有错误..为什么它无法将信息发送到ajaxServer页面...请帮助我找到错误...提前谢谢