Hi All, Im newbie for Yii,
I have try to create Login Form manually, (Not From the General Template).
I want show the Login Form on Fist page.
the Script For Model -> Login_model.php
<?php
class Login_model extends CActiveRecord
{
public static function model($className = __CLASS__)
{
return parent::model($className);
}//end fucntion
public function tablename()
{
return 'user';
} //end fucntion
public function attributeLabels()
{
return Array(
'username'=>'username',
'password'=>'password',
'hak'=>'hak',
);
}//end fucntion
public function rules()
{
return array(
array('username,password','required'),
array('username','length','max'=>'10','filter','filter'=>array($obj=new CHtmlPurifier(),'purify')),
array('password','length','max'=>'10','filter','filter'=>array($obj=new CHtmlPurifier(),'purify')),
array('hak','length','max'=>'10'),
);
}//end fucntion
}
?>
And for Controller -> LoginController.php
<?php
class LoginController extends Controller
{
public $layout="NULL";
public function actionIndex()
{
//$this->render('index');
$data = new Login_model;
if(isset($_POST['Login_model']))
{
$data->username =$_POST['Login_model']['username'];
$data->password =$_POST['Login_model']['password'];
$list= Yii::app()->db->createCommand('select * from user where username=:username AND
password=:password')->bindValue('password',$password)->queryAll();
}//end isset
/*if($list->TRUE)
{
using Session
}*/
}
}
?>
For View->index.php
<div class="form">
<?php echo CHtml::beginForm(array('login/index'));
echo CHtml::errorSummary($data);
?>
<div class="row">
<?php echo CHtml::activeLabel($data,'username');?>
<?php echo CHtml::activeTextField($data,'username','');?>
</div><!--end of row-->
<div class="row">
<?php echo CHtml::activeLabel($data,'password');?>
<?php echo CHtml::activePasswordField($data,'password','');?>
</div><!--end of row-->
<div class="row buttons">
<?php echo CHtml::submitButton('Log In');?>
<?php echo CHtml::endForm();?>
</div>
</div><!--end of form-->
And it show only Blank White Page. The Apache Error Log File is show like this
PHP Fatal error: Call to a member function getErrors() on a non-object in /var/www/septiyo/framework/web/helpers/CHtml.php on line 1592
Can Anyone Help me?
And if You have an Idea to create Login not From default Template, I am ready listen to your advice
Thanks For Advance.