ICTtask works best with JavaScript enabled.

 

CodeIgniter AJAX CRUD using Bootstrap Modal-Create

Live Demo
post thumbnail
Source Code
Hi there, Our Previous tutorial already We have Basic Condeigniter configuration now In this tutorial we discuss about how can CodeIgniter AJAX CRUD using Bootstrap Modal-Create. So first fellow our video to basic configuration then go to ci_crud.php file we have already html markup for create form used to bootstrap framework. When submit our form then we will validation using jquery checking empty field and valid image file format and valid email check by Regular Expression. If else so we will be try send data by ajax ajax response without page refresh. Our ajax url action to controller so now we create a create_update_account method into CI_crud controller and we have a hidden action field value is create into form if our condition matches so we will insert data into Database Table now create a model then create a method into model and write code for insert query so we use codeigniter insert method just pass table name and data, If succsssfull insert so it return true. Now ajax call back function get a string if this string match so we will show a successfull alert. Any problem We have also provide source code or see please in this tutorial. then do this and Fellow our video tutorial We have also provide youtube Video in this post. So Dear, friend please share this my youtube video, subscribe my youtube channel and share this post with your friends. Thanks Next Tutorilas Link these:
    Files structure Fellow:
  • Application root folder
    • aplication/controllers/CI_crud.php
    • //This file is controller class
    • aplication/models/Crud_m.php
    • //This file is model class
    • aplication/views/ci_crud.php
    • // view page

Sourse Code:

  • CI_crud.php - Controller class

  • <?php 
      /**
      *   CI_crud Class
      */
      class CI_crud extends CI_controller
      {
        
        function __construct()
        {
          parent::__construct();
          $curd_m = $this->load->model('curd_m');
        }
    
        public function index(){
          $this->crud();
        }
        public function crud(){
          $this->load->view('ci_crud');
        }
        public function create_update_account(){
          if (isset($_POST['action'])) {
          if ($_POST['action'] == 'create') {
            $table = 'tbl_developers';
            $img ='';
            if ($_FILES['image']['name'] !='') {
              $img = $this->upload_img($_FILES['image']);
            }else{
              $img ='';
            }
            
    
            $data = array(
              'image'=>$img,
              'sex'=>$_POST['sex'],
              'name'=>$_POST['name'],
              'email'=>$_POST['email'],
              'skill'=>$_POST['skill'],
    
            );
            $result = $this->curd_m->createAccount($table,$data);
            if ($result) {
              echo 'created';
            }
          }
    
          }
    
        }
    
        public function upload_img($file){
          $extention = explode('.', $file['name']);
          $newName   = rand().'.'.$extention[1];
          $destination = './assets/upload/'.$newName;
          move_uploaded_file($file['tmp_name'], $destination);
          return $newName;
        }
    
    
    
    
      }
    
    ?>
    
  • Crud_m.php - Model class

  • <?php 
      /**
      * 
      */
      class Curd_m extends CI_Model
      {
        public function createAccount($table,$data){
          $result = $this->db->insert($table,$data);
          return $result;
        }
    
      }
    ?> 
     
    
  • ci_crud.php view page

  • 
     
  • Database file sql

  • 
    --
    -- Database: `developers`
    --
    
    -- --------------------------------------------------------
    
    --
    -- Table structure for table `tbl_developers`
    --
    
    CREATE TABLE `tbl_developers` (
      `id` int(11) NOT NULL,
      `image` varchar(255) NOT NULL,
      `sex` varchar(255) NOT NULL,
      `name` varchar(255) NOT NULL,
      `email` varchar(255) NOT NULL,
      `skill` varchar(255) NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    --
    -- Dumping data for table `tbl_developers`
    --
    
    INSERT INTO `tbl_developers` (`id`, `image`, `sex`, `name`, `email`, `skill`) VALUES
    (5, '6057.jpg', '1', 'Elizabeth N. Bradleyjj', 'Elizabeth@gmail.com', 'python Developer'),
    (6, '23058.jpg', '1', 'Bradley', 'Bradley@gmail.com', 'PHP Developer'),
    (9, '1381.jpg', '2', 'Ruhi', 'ruhi@gmail.com', 'PHP AND JAVA'),
    (10, '3737.png', '1', 'Imrul', 'imrul@gmail.com', 'Python,php'),
    (11, '3819.png', '1', 'kobir', 'kobir@gmail.com', 'Java, C#'),
    (12, '13766.jpg', '1', 'Fahim Ali', 'fahimislam@gmail.com', 'Java'),
    (13, '18438.png', '2', 'Victoria sun', 'victoria.sun@gmail.com', 'Python, Javascript, jQuery'),
    (14, '15604.jpg', '1', 'Programmer Rayhan Mondol', 'icttask.com.rayhan@gmail.com', 'PHP, JAVA, Javascript, Jquery');
    
    --
    -- Indexes for dumped tables
    --
    
    --
    -- Indexes for table `tbl_developers`
    --
    ALTER TABLE `tbl_developers`
      ADD PRIMARY KEY (`id`);
    
    --
    -- AUTO_INCREMENT for dumped tables
    --
    
    --
    -- AUTO_INCREMENT for table `tbl_developers`
    --
    ALTER TABLE `tbl_developers`
      MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
    /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
    /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
    /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
    
    

    Browse by Category

    php Ajax jQuery Codeigniter html css javascript

    Hi there! I am Rayhan Mondol, a PHP & JAVA Developer and ICT task is my programming blog. I'm fond of developing modern web applications. Contact me, I accept the paid task

    Latest Article

    post thumbnail

    Ajax Shopping Cart Customer Order View & account Update by using PHP OOP PDO(E-Commerce website-part 10)

    post thumbnail

    customer accout logout by using PHP OOP, PDO,COOKIE,AJAX(E-Commerce website-part 9)

    post thumbnail

    Customer Account Login by using PHP OOP PDO,AJAX (E-Commerce website-part 8)

    post thumbnail

    Customer Account Create by using PHP OOP PDO (E-Commerce website-part 7)

    post thumbnail

    Remove product from cart by using PHP OOP PDO(E-Commerce website-part 6)

    post thumbnail

    Ajax Shopping Cart update or Edit by using PHP OOP PDO (E-Commerce website-part 5)

    post thumbnail

    Ajax Shopping Cart View and calculate by using PHP OOP PDO (E-Commerce website-part 4)

    post thumbnail

    Drag and Drop Product Add to Cart by using PHP OOP PDO Ajax Jquery - E-Commerce project- (part-3)

    post thumbnail

    Product Add to Cart using PHP OOP PDO Ajax JQuery - E-Commerce project- (part-2)

    post thumbnail

    Create Dynamic Tabs using PHP OOP PDO - E-Commerce project- (part-1)

    post thumbnail

    CodeIgniter AJAX CRUD using Bootstrap Modal - Delete

    post thumbnail

    CodeIgniter AJAX CRUD using Bootstrap Modal Edit or Update

    post thumbnail

    CodeIgniter AJAX CRUD using Bootstrap Modal Read or view

    post thumbnail

    CodeIgniter AJAX CRUD using Bootstrap Modal-Create

    post thumbnail

    CodeIgniter AJAX CRUD(setup removing index.php from url)