ICTtask works best with JavaScript enabled.

 

PHP AJAX CRUD using mysqli - create or Insert

Live Demo
post thumbnail
Source Code
Hi, Every one In this tutorial of Creating CURD Application system by using PHP and Msqli With ajax. you will learn how can you create or Insert or Add data into Mysql Database table by using php procedural form programming style and without page refresh by using ajax response. So You can also check demo online. We have also provide demo link And source code download link with this post. In this tutorial we have seen not only how can you create or insert data into mysql Database even you can learn how to upload image by using Ajax Response Without page Refresh with PHP procedural foorm style. So our need to do this a create form. we have use Bootstrap & Popeller Form & Collapse style, First I can hide form on web page, but when we want to add new data then at that time you can visible form on web page so we can hide large amount of content on web page but here we have use for hide form. This is unique concept of Advance technology. you can also use in your web Application project best of luck. This is best way to do this. So If you use Bootstrap & Propeller even we not use browser default alert, We use sweet alert for this nice alert for user friendly. so must be load include bootstrap's css and js and Propeller's css and js files by using Download or CDN link for these files. For this We have create Database db_phpajax into table tbl_employee, no problem We have also provide sql file with source code or see please in this post. So do this and Fellow our video tutorial We have also provide youtube Video in this post. In next video tutorial we will make discussing on how to select all rows from Mysql table by using PHP AJAX MySqli. So please share this youtube video, subscribe my youtube channel and share this post with your friends. Thanks Next Tutorilas Link these:
    Files structure Fellow:
  • Application root folder
    • upload
    • //This Folder into upload files
    • action.php
    • //This file will handle for Insert data to Database Table
    • index.php
    • //This file for view Create form

Sourse Code:

  • action.php

  • <?php 
      $connect = mysqli_connect("localhost","root","","db_phpajax");
    
      if (isset($_POST['action'])) {
        if ($_POST['action'] == 'create') {
          $firstName = mysqli_real_escape_string($connect,$_POST['firstName']);
          $lastName = mysqli_real_escape_string($connect,$_POST['lastName']);
          $designation = mysqli_real_escape_string($connect,$_POST['designation']);
    
          $imageName = img_upload($_FILES['image']);
    
          $query = "INSERT INTO tbl_employee(fName,   lName,designation,image) VALUES('".$firstName."','".$lastName."','".$designation."','".$imageName."')";
          if (mysqli_query($connect,$query)) {
            echo 'create';
          }
        }
      }
    
      function img_upload($file){
        $extention = explode('.', $file['name']);
        $newNmae   = rand().'.'.$extention[1];
        $designation = 'upload/'.$newNmae;
        move_uploaded_file($file['tmp_name'], $designation);
        return $newNmae;
      }
    ?>
    
  • index.php

  • 
    
  • Database file sql

  • --
    -- Database: `db_phpajax`
    --
    -- --------------------------------------------------------
    --
    -- Table structure for table `tbl_employee`
    --
    CREATE TABLE `tbl_employee` (
      `id` int(11) NOT NULL,
      `fName` varchar(255) NOT NULL,
      `lName` varchar(255) NOT NULL,
      `designation` varchar(255) NOT NULL,
      `image` varchar(255) NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    --
    -- Dumping data for table `tbl_employee`
    --
    
    INSERT INTO `tbl_employee` (`id`, `fName`, `lName`, `designation`, `image`) VALUES
    (37, 'Roman ', 'Mondol', 'Teacher ', '22230.jpg'),
    (38, 'Aslam ', 'Hasib', 'Wordpress Developer', '23895.png'),
    (39, 'Md Ibrahim ', 'Islam', 'Writer', '10512.png'),
    (52, 'Aslam', 'Khan', 'Media Expert', '15945.png'),
    (59, 'Programmer', 'Rayhan Mondol', 'JAVA and PHP Developer', '28556.jpg');
    
    --
    -- Indexes for dumped tables
    --
    
    --
    -- Indexes for table `tbl_employee`
    --
    ALTER TABLE `tbl_employee`
      ADD PRIMARY KEY (`id`);
    
    --
    -- AUTO_INCREMENT for dumped tables
    --
    
    --
    -- AUTO_INCREMENT for table `tbl_employee`
    --
    ALTER TABLE `tbl_employee`
      MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=60;
    /*!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)