Yii Framework Forum: آیا به این شیوه چک کردن صحیح است !؟ - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

آیا به این شیوه چک کردن صحیح است !؟

#1 User is offline   abedi98 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 86
  • Joined: 29-August 11

Posted 05 March 2012 - 03:19 AM

سلام دوستان

من مثلاً یک فرم لاگین میخواستم درست کنم و به صورت زیر عمل کردم ، آیا این روش از نظر امنیتی و بقیه موارد صحیح است !؟ و آیا اینکه شما نظر بهتری دارید !؟


UserController.php

class UserController extends Controller
{
	public function actionIndex()
	{

		$this->render('index');

		
	}
	
	public function actionLogin()
	{
		$model = new User();
		$this->render('login',array('model'=>$model));
		if(isset($_POST['User']))
		{
			$username = $_POST['User']['username'];
			$password = $_POST['User']['password'];
			$User = User::model()->find('username=:username AND password=:password',array(':username'=>$username,':password'=>$password));
			echo count($User);
		}
	}
	
}


view/user/login.php

<?php 
$form = $this->beginWidget('CActiveForm'); 
	echo $form->labelEx($model,'username');
	echo $form->textField($model,'username');
	echo $form->error($model,'username');
	echo '<br />';
	echo $form->labelEx($model,'password');
	echo $form->passwordField($model,'password');
	echo $form->error($model,'password');
	echo '<br />';
	echo $form->labelEx($model,'button');
	echo CHtml::submitButton();
	echo $form->error($model,'button');
$this->endWidget(); 
?>

0

#2 User is offline   naser 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 85
  • Joined: 30-October 09
  • Location:tehran - Iran

Posted 06 March 2012 - 02:48 AM


این صقحه رو بخون
http://www.yiiframew...ogin-and-logout

1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users