6

Yii 2.0 Basic User Login From Database

Before start the application login steps,

  • First create a database table with your own requirements.
  • Now go to the Model generator and create a Model using the user table
  • It will generate a User model. In this model you will have to
    implement the IdentityInterfaceclass User extends \yii\db\ActiveRecord implements \yii\web\IdentityInterface
  • Now in Login form you will have to define User model so it will return back the userclass LoginForm extends Model { public $username; public $password; public $email; public $rememberMe = true;

User Table:(user.sql)

 

User Model:(user.php)

 

User Search Model:(UserSearch.php)

 

User Controller:(UserController.php)

 

Site Controller:(SiteController.php)

 

Login Form:(login.php)

That’s it this will solve your problem.

 

 

Prakash S

Prakash S

I would like to introduce myself as a Software professional opting for the career in software industry. I'm Prakash S, a MCA graduate and trained as industry level practice for Software technology. Basically I am a PHP Developer but now days exploring more in HTML5, CSS, AngularJS and jQuery libraries.