Posts Tagged ‘Codeigniter’
Creating Register and Login Form Using EXTJS and CodeIgniter
Like another tutorial this post will create the basic form login and register using Extjs and Codeigniter, and I want to mix my previous post about Codeigniter Session Library, Extjs Unique Field Validation and using Statusbar in Extjs Window.
1. Setting up the database
Using phpmyadmin in XAMPP I create the database named “ci_extjs_login”, and create simple “users” table, here below is the sql code that I generated from phpmyadmin, for more advance database modelling you can use mysql workbench.
CREATE TABLE `ci_extjs_login`.`users` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `username` VARCHAR( 100 ) NOT NULL , `password` VARCHAR( 100 ) NOT NULL , `email` VARCHAR( 100 ) NOT NULL ) ENGINE = MYISAM ;
Creating user session checking with CodeIgniter library
When we build web application with user authentification, the application must have user login/logout or signin/signout or whatever you called it, then the system must have user logged feature to check whether the user is logged in or logged out. Session is the most common way to checking it. In Codeigniter, using Session Class you can use simple function inside controller, it’s something like this:
class User extends Controller {
// constructor class
function __construct()
{
parent::Controller();
$this->load->library('session');
}
function index()
{
$this->load->view('user/index');
}
function login()
{
// if user already logged in, redirect to user index
if ($this->_is_logged_in())
{
redirect('user/index');
}
else
{
$this->load->view('user/login');
}
}
function register()
{
// if user already logged in, redirect to user index
if ($this->_is_logged_in())
{
redirect('user/index');
}
else
{
$this->load->view('user/register');
}
}
// checking user logged user by registered session
function _is_logged_in()
{
$logged = $this->session->userdata('user_id');
if ($logged)
{
return TRUE;
}
else
{
return FALSE;
}
}
}
Various CodeIgniter wallpaper
CodeIgniter is one of the most popular PHP framework because is easy to learn, have a great documentation, and personally i use it now. Here some CodeIgniter Wallpaper created by the community. Most of them created by nucleocide from devianart thanks for your great work.
1920 x 1200 pixels
