Codeigniter Sample Application
Introduction
CodeIgniter is the simplest PHP Framework which I have ever tried. There are enough tutorials available. It is simple to understand, if you know PHP surely.
The following is one of the simple application created using CI.
Controller Class:
<?php
Class Logins extends CI_Controller {
public function index()
{
$this->load->view('header', array('page'=>'login'));
$data = array('title' => 'Login');
$this->load->view('display_login', $data);
}
function ajax_check_login()
{
$this->load->model('user_model');
$user_id = $this->user_model->ajax_check_login_model();
if ($user_id)
{
$this->create_session($user_id);
echo 1; // valid
} else {
echo -1; //invalid
}
}
public function create_session($user_id)
{
$this->load->library('session');
if($this->session) {
$user_name = $this->user_model->get_user_name($user_id);
$this->session->set_userdata(array(
'user_id' => $user_id,
'user_name' => $user_name
));
}
}
public function home()
{
.......
.......
}
public function signout()
{
.......
.......
}
public function insert_user()
{
.......
.......
}
}
No comments:
Post a Comment