我刚才编辑的“window.location的”和零件的onClick其中adminhome.php为管理员和crewhome.php为职工

+3

你假定每个人都有一个独特的密码? :) – 2014-11-25 02:10:44

+3

所以你现在*开发一些使用不推荐的'mysql_'函数?个人不想聘请你作为开发人员。 – 2014-11-25 02:15:32

$query=mysql_query("update account set acc_pword='$acc_pword2' where acc_pword='$acc_pword';")or die("JBSOFTWARES 1".mysql_error()); 

此行更新任何和所有帐户密码为$acc_pword。您需要将更新限制为当前登录的用户。

+0

我该怎么做? – 2014-11-25 02:10:09

+1

@RanierLizada通过添加'AND acc_uname ='$ acc_uname'' ...说,你应该(不,必须)在SQL中正确地转义你的变量。 – 2014-11-25 02:12:10

+0

它的工作原理。谢谢 – 2014-11-25 02:18:25

而不是在WHERE子句中使用密码本身,我建议使用用户帐户。那么不可能改变错误的密码。

变化:

$query=mysql_query("UPDATE account SET acc_pword='$acc_pword2' 
      WHERE acc_pword='$acc_pword';")or die("JBSOFTWARES 1".mysql_error()); 

要:

$query=mysql_query("UPDATE account SET acc_pword='$acc_pword2' 
      WHERE acc_uname='$acc_uname';")or die("JBSOFTWARES 1".mysql_error()); 
+0

如果你提供了一个正确转义的例子,我会对此赞不绝口 – 2014-11-25 02:15:15

+0

@JonathanGray你是指一个准备好的查询吗? – EternalHour 2014-11-25 03:33:27

第一个答案是正确的,并回答你的跟进问题。你只需要了解你的查询条件..

变化

$query=mysql_query("update account set acc_pword='$acc_pword2' where acc_pword='$acc_pword';")or die("JBSOFTWARES 1".mysql_error()); 

$query=mysql_query("update account set acc_pword='$acc_pword2' where user_id = currentUser;")or die("JBSOFTWARES 1".mysql_error()); 
+0

感谢那 – 2014-11-25 02:21:33

+0

请接受我的答案,如果它可以帮助你 – 2014-11-25 02:25:33

相关推荐