CodeIgniter Tutorial – CI MVC Framework Project

CodeIgniter tutorial :- Codeigniter has a based framework of php. It has a reusable capability in this framework its has also used MVC (model view controller ).

So Here is a each solution of codeigniter by the web learn smart . we also provide a codeigniter pdf with example.

Codeigniter Tutorial step by step

Here is list of about codeigniter and describe all point below.

  • What is codeigniter.
  • Why we use codeigniter.
  • How to install.
  • Codeigniter file structure.
  • How to setup codeigniter step by step.
  • How to use codeigniter with example.
  • How to use MVC(model view controller ) in codeigniter.
  • How to make small project in CI with example.
  • Provide all link insert data, update,select and delete in CI.

What is Codeigniter

Codeigniter is a open source web application framework. It has providing powerful tools for developer. It can be use friendly each task.

It is handle and create helps in creating powerful web applications with more structure and designing in programming.

Codeigniter provies more then own functionality of reusable source code for better web application.

Why We use Codeigniter

We should be mostly prefer powerful framework codeigniter for web application. It has php open source framework and here are more then codeigniter tools.

codeigniter tools helps for developer reusable codes with the help of CI.

It has a popular framework of php for web application. Provides all source codes and guide step by step. Go to codeigniter official websites codeigniter user guide How to install.

How to Install Codeigniter

Here are some step and follow those step.

Go to web search type codeigniter we provide the link download codeigniter here. After that go to server directory put this download files.

  • If you are using local wamp/xampp server so put files www file.
  • Default file name is codeigniter. If you change project name you can change.

Thus Now you can see all CI file directories and start your projects.

codeigniter tutorial

Codeigniter File Structure

Here are both types files folder in which default and user So we are using for custom codes users. you Can see image file structure.

codeigniter tutorial

After that Now going to tools firstly we are using user tool. So in these files click application files there are more then files see above image.

Cache :- So top of the files cache we are using this files define our cache data.

Config :- In this files more then sub files so i describe in which using. we can be use database files here is automatic crate database code therefore we take to do only name of database.

This config Files only using directories file path in which we using in own projects.

Libraries:- In this files using default tools like form and database.

Helpers :- In this files similar libraries like validation card and url.

How to use Codeigniter with example

When you have to done setup your files and run your projects on the browser again you see interface your page output.

check your address bar and put link of your projects see below image also check another about bank login system HDFC NetBanking Login Forgot Password

http://projectsname.com and localhost/projectname

codeigniter tutorial

How to use MVC (Model View Controller) in Codeigniter

Model view controller is a structure in which using developer while programming. this structure very easily useful and helpful. Through this pattern easily control codes.

Model :- When you are writing code of database query and login in this file this is back end. So firstly you crate a file for model and also mention your class and function in this files.

View :- It is a interface here is mention only front end area codes.

Controller:- controller to do control both file model and view and also response by the user and take action through the controller also mention login in this files.

Model.php


<?php

class Name extents ModelCI
{

Public funtion ()
{
	
echo "here your model codes....";
}

}



?>

View.php

<!DOCTYPE html>
<html>
<head>
	<title>403 Forbidden</title>
</head>
<body>

<p>Directory access is forbidden.</p>

</body>
</html>

Controller.php

<?php 
defined('BASEPATH') OR exit('No direct script access allowed');

Class Home extends CI_controller
{
	public function show()
	{
		$this->load->view('home');
	}
}

 ?>

Basic project in Codeigniter

Here are model files source codes login user .

loginuser.php

<?php 

class loginmodel extends CI_Model
{
	public function isvalidate($username,$password)
	{
		// $q=$this->db->where('username','password')
					// ->where($username,$password)
		            // ->get('users');
		          $q=$this->db->get_where('users', array('username' => $username,'password' => $password));
		            
		            if($q->num_rows())
		            {
		            	return $q->row()->id;
		            }
		            else{
		            	return false;
		            }
	}

	public function articlelist()
	{
		$id=$this->session->userdata('id');
		$q=$this->db->select('article_title')
				->from('articles')
				// ->where(['id'=>$id])
				->get();
				return $q->result();
	}
}


 ?>

Here are view part of files source codes.

login.php

 <!DOCTYPE html>
 
<?php include('header.php');?>

<div class="container"style="margin-top: 20px;">
	<h1>Admin Form</h1>
<?php echo form_open('admin/index'); ?>
	<div class="row">
		<div class="col-lg-6">
	<div class="form-group">
		<label for="username">username :</label>
		<input type="text" class="form-control" id="email" name="uname">
	</div>
   </div>
   <div class="col-lg-6">
   	<?php echo form_error('uname'); ?>  
   </div>
	</div>
	<div class="row">
		<div class="col-lg-6">
	<div class="form-group">
		<label for="pass">password :</label>
		<input type="password" class="form-control" id="pwd" name="pass">
		</div>
   </div>
   <div class="col-lg-6">
   	<?php echo form_error('pass'); ?>  
   </div>
	</div>

	
	<button type="submit" class="btn btn-default">submit</button>

</div>
<?php include('footer.php');?>

Here are controller files source codes.

admin.php

<?php 
class Admin extends MY_Controller
{
 	// public function __construct() {

 	// 	parent::__construct();
 	// 	if($this->session->userdata('id'))
  //        	return redirect('admin/welcome');
 	// }

  public function index()
	{
		$this->load->library('form_validation');
		$this->form_validation->set_rules('uname','user name','required|alpha');
		$this->form_validation->set_rules('pass','password','required');

		if($this->form_validation->run()){

         $uname=$this->input->post('uname');
         $pass=$this->input->post('pass');
         $this->load->model('loginmodel');
         $id=$this->loginmodel->isvalidate($uname,$pass);
         if($id)
         {
         	$this->load->library('session');
         	$this->session->set_userdata('id',$id);
         	return redirect('admin/welcome');
         }
         else{

         	echo "details nor matched";
         }

		}
		else{
			$this->load->view('admin/login');
		}
	}
	
	public function welcome(){

		$this->load->model('loginmodel');
		$articles=$this->loginmodel->articlelist();
		$this->load->view('admin/dashboard', array('articles'=> $articles));

	}
}


 ?>

users.php

<?php 
class Users extends MY_Controller
{
public function index()
	{
		$this->load->view('users/articlelist');
	}

}


 ?>

So We will soon gives to you codeigniter projects Insert update select and delete we will provide link soon.

Another you want to learn about Python Absolute Value click and check.

Also learn you can see HTML Syntax Example on this link post.

8 Comments

Add a Comment
  1. I’m extremely impressed with your writing skills as well as with the layout on your blog.
    Is this a paid theme or did you modify it yourself?

    Anyway keep up the excellent quality writing, it is rare
    to see a nice blog like this one today. It is the best time to make some
    plans for the future and it’s time to be happy.
    I’ve read this post and if I could I desire to suggest you few interesting things or suggestions.
    Maybe you could write next articles referring to this article.

    I wish to read more things about it! I’ll immediately grab your rss feed as I can not to find your email subscription hyperlink
    or e-newsletter service. Do you have any? Please allow me understand so
    that I may subscribe. Thanks. http://starbucks.com

  2. 965099 539059I like this post a good deal. I will surely be back. Hope that I is going to be able to read far more insightful posts then. Will probably be sharing your expertise with all of my associates! 829071

  3. Way cool! Some extremely valid points! I appreciate you
    penning thiss article and the rest of the website
    is also really good.

  4. Cialis and viagra together viagra order cialis online 37.5 buy cheap cialis online

  5. When I originally commented I seem to have clicked
    on the -Notify me when new comments are added- checkbox and now every time a comment is added I
    recieve four emails with the same comment. There has to be an easy method you are able to remove me from that service?
    Thanks a lot!

  6. Some truly nice and useful info on this site, too I think the layout holds fantastic features.

  7. Hi to every body, it’s my first pay a quick visit of this web site; this blog carries remarkable and really good information designed for readers.

Leave a Reply

Your email address will not be published. Required fields are marked *

Web Learn Smart © 2019 Frontier Theme