Lockout Feature To Disable Users

Hello, I’m a newbie when it comes to Yii Framework and what I know is Java so I can easily adapt to PHP. I’m trying to create a lockout feature for users who failed to input correct password for a maximum of three(3) attempts. I’ve tried making a get-set function in my login button with a counter, so that everytime I call on that function it adds 1 to my counter. Then, when my counter reaches 3 it creates a temptable or insert ‘true’ for disabled column in my database for disabled users. But it gives me errors, it says in my syntax.

Windows 7 Ultimate, XAMPP, Firefox, Yii 1.1.4.r2429


public function login()

	{

		if($this->_identity===null)

		{

			$this->_identity=new UserIdentity($this->username,$this->password);

			$this->_identity->authenticate();

		}

		if($this->_identity->errorCode===UserIdentity::ERROR_NONE)

		{

			$duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days

			Yii::app()->user->login($this->_identity,$duration);

			

			// Connect to database.

			$con = mysql_connect('localhost', 'root', '') OR die(mysql_error());

			mysql_select_db('mydb', $con) OR die(mysql_error());

		

			// Insert query into database.

			mysql_query("INSERT INTO logs_login (dateline, ipaddress) VALUES ('". time() ."', '". $_SERVER['REMOTE_ADDR'] ."')") OR die(mysql_error());

		

			return true;

			

		

		}

		else

		

		[color="#FF0000"]//Call getter and setter here.

		

			// Insert query into database.

			mysql_query("INSERT INTO account_employee (disabled) VALUES ('". true ."')") OR die(mysql_error());

			}[/color]

			

			return false;

	}

I think something is wrong with my getter and setter.


[color="#FF0000"]private $counter;[/color]

	

	[color="#FF0000"]//Getter

	public function getName(){

		return $this->name;

	}

	

	//Setter

	public function setName($name){

		$this->name = $name;

	}

[/color]

TIA :)

The getter and setter don’t seem to be related to the variable. Have you posted the wrong part of the class?

I would highly recommend you look into ActiveRecord or Query Builder,

http://www.yiiframework.com/doc/guide/1.1/en/database.query-builder

Variables shouldn’t be used directly in the query.

@Keith - I’ve posted the right code, but it seems irrelevant. Do you mind telling me what’s wrong with it?

@alex-w - Thank you for your answer.