Mysql Update查询更新功能

时间:2015-05-20 05:06:01

标签: php mysql

class loginattempts{
    public $max_attempts = 5;

    public function loginAttempts(){
    global $ALIST;
    $user_ip = $_SERVER["REMOTE_ADDR"];
    $user_locked = "locked";


if($user_max_attempts >= $this->max_attempts){
            // update ip statue to locked //
            $attemtps_pdo = "UPDATE `attempts` SET `USER_STATUS`= ? WHERE IP = ?";
            $results = $ALIST->update($attempts_pdo,$user_locked,$user_ip);
            echo " locked";
        }else{
            // update ip attemtps ++ 1 //
            //add sql injection // 
            $attemtps_pdo = "UPDATE `attempts` SET `MAX_ATTEMPTS`= ? +1 WHERE IP = ?";
            $results = $ALIST->update($attempts_pdo,"MAX_ATTEMPTS",$user_ip);
            echo " is not locked";
        }
}

db.php中

class data{

public function update($sql,$values1,$values2){
    $results = $this->connection->prepare($sql);

    $results->bindValue(1,$values1);
    $results->bindValue(2,$values2);
    $results->execute();
}

$ALIST = new Data;

}

与数据库的连接没有问题,但是一旦我绕过我的UPDATE查询进行功能更新,我的数据库就不再更新,我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

检查您班级的拼写,您使用了班级数据,但这= $ ALIST =新数据;

更改拼写,然后重试它们必须匹配。

尝试在loginattempts类的数据类中指定update方法以避免任何全局变量