Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 更改管理员帐户的密码也会影响员工帐户_Php_Html_Web_Admin - Fatal编程技术网

Php 更改管理员帐户的密码也会影响员工帐户

Php 更改管理员帐户的密码也会影响员工帐户,php,html,web,admin,Php,Html,Web,Admin,我需要一点帮助。我目前正在开发我公司的网站,一切都很顺利,直到我测试了管理员帐户(我使用)的更改密码功能。我已经为员工建立了一个单独的帐户,它有自己的更改密码功能。我的问题是,每当我更改密码时,它也会将员工帐户的密码更改为相同的密码 以下是更改密码的PHP代码: <?php session_cache_limiter("private"); $cache_limiter = session_cache_limiter(); session_cache_expire(180); $cache

我需要一点帮助。我目前正在开发我公司的网站,一切都很顺利,直到我测试了管理员帐户(我使用)的更改密码功能。我已经为员工建立了一个单独的帐户,它有自己的更改密码功能。我的问题是,每当我更改密码时,它也会将员工帐户的密码更改为相同的密码

以下是更改密码的PHP代码:

<?php
session_cache_limiter("private");
$cache_limiter = session_cache_limiter();
session_cache_expire(180);
$cache_expire=session_cache_expire();
session_start();
if(isset($_SESSION['acc_uname'],$_SESSION['acc_pword']))
{
$acc_uname=$_SESSION['acc_uname'];
$acc_pword=$_SESSION['acc_pword'];
require_once('/home/a9440778/public_html/registration/connect.php');
function escape_data($data)
{
global $dbc;
if(ini_get('magic_qoutes_gpc'))
{
$data=stripslashes($data);
}
return mysql_real_escape_string($data,$dbc);
}
error_reporting(E_ALL & ~E_NOTICE);
echo"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />
<title>
Natuna Scean Manpower Corporation
</title></head>";
if(empty($_POST['acc_pword1']))
{
$acc_pword1=false;
echo"<b>Old Password</b> Contains null value<br>";
$retry=1;
}
else if($_POST['acc_pword1_err']=='1')
{
$acc_pword1=false;
echo"<b>Old Password</b> Contains invalid value<br>";
$retry=1;
}
else
{
$acc_pword1=md5(escape_data($_POST['acc_pword1']));
}
if(empty($_POST['acc_pword2']))
{
$acc_pword2=false;
echo"<b>New Password</b> Contains null value<br>";
$retry=1;
}
else if($_POST['acc_pword2_err']=='1')
{
$acc_pword2=false;
echo"<b>New Password</b> Contains invalid value<br>";
$retry=1;
}
else
{
$acc_pword2=md5(escape_data($_POST['acc_pword2']));
}
if(empty($_POST['acc_pword3']))
{
$acc_pword3=false;
echo"<b>Retype Password</b> Contains null value<br>";
$retry=1;
}
else if($_POST['acc_pword3_err']=='1')
{
$acc_pword3=false;
echo"<b>Retype Password</b> Contains invalid value<br>";
$retry=1;
}
else
{
$acc_pword3=md5(escape_data($_POST['acc_pword3']));
}
if($acc_pword3!=$acc_pword2)
{
$acc_pword3=false;
$acc_pword2=false;
echo"<b>New Passwords</b> do not match each other<br>";
$retry=1;
}
if($acc_pword1!=$acc_pword)
{
$acc_pword1=false;
echo"<b>Old Password</b> does not match<br>";
$retry=1;
}
if($retry=='1')
{
echo"<br><br><a href='javascript:history.go(-1)' target='middle'>retry encoding</a>";
}
else
{
echo"<script>

alert('Password Update Successful!');
window.location='http://natunascean.site88.net/admin/adminhome.php';
</script>";

/* echo"
<br><b>You had successfully updated your account</b><br><br>
<a href='' onclick='window.adminhome.php.reload(true)'>Done</a>"; */
$query=mysql_query("update account set acc_pword='$acc_pword2' where acc_pword='$acc_pword';")or die("JBSOFTWARES 1".mysql_error());
$_SESSION['acc_uname']="$acc_uname";
$_SESSION['acc_pword']="$acc_pword2";
$_SESSION['acc_type']="$acc_type";
}
}
else
{
echo"<center><br><br><img src='ops.png'></center>";
}
?>

我刚刚编辑了“window.location”,并单击了adminhome.php和crewhome.php中的部分

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

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

与其在
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_pword='$acc_pword';")or die("JBSOFTWARES 1".mysql_error());


您假设每个人都有唯一的密码?:)那么您目前正在开发一些使用不推荐的
mysql\uuz
函数的东西?我个人不想雇用你作为开发人员。@RanierLizada通过添加
和acc_uname='$acc_uname'
。。。也就是说,你应该(不,必须)正确地转义SQL中的变量。@RanierLizada现在研究一下为什么
mysql\u*
函数不好用(它们被弃用并消失了),以及SQL注入如何让你的整个站点受到攻击。我如何防止这种情况发生?@RanierLizada通过学习良好的开发实践。其中之一就是学习故障排除和研究。开始吧,谢谢,先生。真的很感激that@JonathanGray您是指准备好的查询吗?
$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());