Professional CodeIgniter, Thomas Myer

Chapter 6: Creating a Dashboard
149
Here ' s a basic controller stub for admin/dashboard:
class Dashboard extends Controller {
function Dashboard(){
parent::Controller();
session_start();
}
}
And here ' s the basic controller stub for admin/products:
class Products extends Controller {
function Products(){
parent::Controller();
session_start();
}
}

Next is the basic controller stub for admin/categories:
class Categories extends Controller {
function Categories(){
parent::Controller();
session_start();
}
}

Finally, this is the basic controller stub for admin/admins:
class Admins extends Controller {
function Admins(){
parent::Controller();
session_start();
}
}


Creating the Login Mechanism

Before you can continue building out the administrative controllers, it ' s a good idea to create a login and
verification process to allow admins access to the secure area.

The process is pretty simple. All you need to do is create a
login()

function in the Welcome controller
and then tie it to a view and a model that will check for the proper administrative privileges. The model
will, of course, need to be tied to a database table with information stored for each admin.

So before doing anything else, create a simple database table called admins that has ID, username, e - mail,
password, and status fields. Make the status field an enum with two states, active and inactive. Also,
make sure that both the username and e - mail fields are unique.
c06.indd 149
c06.indd 149
6/10/08 5:35:58 PM
6/10/08 5:35:58 PM


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.