2012-06-29 27 views
-2

我在一个网站上工作,我必须重置页面上的密码脚本。对于我使用AJAX传递新旧密码,并希望得到在同一页上的结果使用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 Script的值传递给页面名称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页面...请帮助我找到错误...提前致谢

+2

请告诉我该网站的名称,所以我记得从来没有用我的密码信任它。 –

+2

您有一个SQL注入漏洞。 – SLaks

+2

**永不**以纯文本格式存储密码。 – SLaks

回答

0

指定error属性只是成功,这样你才能发现错误。