Yii register User with Email

Ill introduce how to make a simple email registration with Yii Forms and using an email extension for yii.
If you haven’t installed any email extensions check this post Yii email extension

Step 1 – Create the user table

Step 2 – Create the form using Gii

If you dont know what gii is check here Gii
To create the form you will need the user model which also can be created with gii, as long as you have the table in your database

  1. After creating the form a register.php will be created under views
  2. Put that register.php under site folder
  3. Also a code will be shown when you create the form, thats the action for the form
  4. Copy and paste that code in to your SiteController.php

Step 3 – Add a link to register.php

Find and change the part in main.php under views/layouts to look like this

Step 4 – Controller Register Action

For simplicity I’ll ask for a username and email to register, Adding other fields is pretty easy with Yii.

Step 5 – Activation Page and Action

Notice that these fields are hidden and will get their values from the Url, on submit the activation action will be called

Recent Posts