SoftwareQuery
Home About Contact

Registration Form In Codeigniter Using Ajax And jQuery

 SoftwareQuery     5 comments   


JQuery’s mythical being strategies extremely created straightforward to post information a knowledge an information and come back that data while not refreshing the page. We are able to apply this jQuery mythical being post in CodeIgniter still. Before continuing any we tend to take into account that you just square measure a touch at home with CodeIgniter PHP framework. With the assistance of Associate in Nursing example, you'll find out how to post information to a controller victimization the CodeIgniter jQuery mythical being methodology.

Friend's if you don't  know how to install Codeigniter in localhost or sever read my last post click this link -https://www.softwarequery.com/2018/02/how-to-install-codeigniter-on-localhost.html


Step-1. We create an HTML code in index.php

   
   <!DOCTYPE html>
           <html>
           <head>
           <title>Registration | SoftwareQuery</title>
            </head>
            <body>
         <body>
     <form id="form" method="post">
        <table>
            <tr>
              <td>Name:</td>
              <td><input type="text" name="name" id="name"/>
           </tr>
           <tr>
             <td>Email:</td>
             <td><input type="email" name="email" id="email">
          </tr>
         <tr>
        <td colspan="2">
             <input type="button" name"submit" id="submit"> 
        </td>
         </tr>
        </table>
      <span id="p1" style="display:none;"> Success</span>
      <span id="p2" style="display:none;">Error</span>
     </form>
   </body>
   </html>
-----------------------------------------------JQuery Code-------------------------------------------

Step- 2. Search html code ctrl+F this tag </head> and put the script.


             <script src="https://ajax.googleapis.com/ajax/libs/dojo/1.13.0/dojo/dojo.js"></script>


-----------------------------------------<Script>...................................................................................

Step-3. Go got HTML code and press button ctrl+f search </body> tag put this script.

             <script>
           $(function(){
      $('#p1').hide();
      $('#p2').hide();
     $("#submit").click(function(){
        var empty = false;
        $('#name').each(function() {
            if ($(this).val().length == 0) {
                empty = true;
            }
        });
        if (empty) {
            $('#p2').fadeIn();
            $("#p2").delay(2000).fadeOut();
        }
         else {
            var empty = false;
            $('#email').each(function() {
            if ($(this).val().length == 0) {
                empty = true;
            }
        });
        if (empty) { 
            $('#p2').fadeIn();
            $("#p2").delay(2000).fadeOut();
        }
        else{
         var name = $("input[name=name]").val();
         var email = $("input[name=email]").val();
         $.ajax({
            type: "POST",
            url: "<?php echo base_url('controoler_name/insert/'); ?>",
            data: {name:name,email:email},
            success: function() {
              $('#p1').fadeIn();
              $("#p1").delay(2000).fadeOut();
               $('#form').find("input[name=name], input[name=email]").val("");
            } 
           })
          }
})
</script>
----------------------------------------------Create Model---------------------------------------------

Step-4. Go to Model Folder and open create new model file save any name the put this code. After put, code go to the browser and type localhost/phpmyadmin create new database name then make two field email, name.

         function insert($name,$email)
           {
        $data = array(
        'column_name'=> $name,
         'coulmn_name_email' => $email
          );
        $this->db->insert('table_name',$data);
        return true;
         }
           
.............................................................Create Controller...................................................................

Step-5. Go to controller Folder and open new model file save any name the put this code.

            function insert(){
  $name= $this->input->post('cname');
  $email= $this->input->post('cemail');
  if(($cname=='')||($cemail=='')){
   echo 'error';
  }else
  $data = $this->model->insert($name,$email);
  if($data == 'true'){
  echo 'success';
  else
 {
 echo 'error';
 }
}
}





  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to TwitterShare to Facebook
Newer Post Older Post Home

5 comments:

  1. Anonymous9 September 2018 at 13:10

    I loνed aѕ muсh as you will recеive carried out right herе.
    The sкetch is attractіve, your authored subject matter stylish.
    nonetheless, you command get got an impatience over that you wish be ⅾelivering the following.
    unwell unquestionably come fuгther formerly again as еxaсtly
    the same nearly very often insidе caѕe you
    shield this increase.
    helpful resources : How To Learn To Password Ⲣrotect Folder In 1 Hour

    ReplyDelete
    Replies
    1. SoftwareQuery11 September 2018 at 11:18

      Thanku buddy

      Delete
      Replies
        Reply
    2. Reply
  2. Anonymous11 September 2018 at 22:19

    Ԝrite more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.
    You definitely know what ʏoure talking about, why ᴡaste your intelligence on just posting vіdeoѕ to your blog
    whеn you could be giving us something enlightening to read?


    more : Loсk Fiⅼes It: Herе’s How

    ReplyDelete
    Replies
      Reply
  3. Anonymous18 September 2018 at 11:04

    My brother recommended I might liкe this blog. He was totallу right.
    This p᧐st actually made my day. You can not іmagine
    just how much time I had spent for this іnformаtion!
    Thanks!
    go to tһis site : How To Learn To Pasѕword Protect Folⅾer Just 15 Minutes A Day

    ReplyDelete
    Replies
      Reply
  4. Anonymous30 December 2019 at 05:02

    555

    ReplyDelete
    Replies
      Reply
Add comment
Load more...

Donate

Translate

Popular Posts

  • How to Make Image Upload Code Using AJAX
    Direct Copy Paste PHP File  Image Upload Code -   <html> <head> <meta charset="utf-8"> <meta http-equi...
  • Best Useful Free Plugin to Make Wordpress Theme
    Meta Slider   - Meta Slider is that the initial free possibility on today’s list. A premium version is additionally obtainable...
  • How To Install Magento on Localhost XAMPP OR WAMP SERVER
      Step-1 => Make Sure you have to install Latest Version of  Xampp server or Wamp server in your PC.   Step -2 => Go to Web Bro...
  • How To Intall Node.js Via Command On Window And Linux.
    Step-1 . Firstly We have to go official website of https://nodejs.org/en/ then download the latest version of Nodejs zi...
  • How to Set up Amazon Affiliate Marketing Account to Earn Money
    Amazon Associates is a  marketing of Amazon company. It is allowed to youtube channel owner, Social Media pages owner and any type...
  • How To Create Custom Pagination In WordPress
    Hello, Friend's in this post we are creating a custom code of Pagination in WordPress. It is very easy to put this code any custom...
  • How to create facebook share and like button for webpage
    Step-1 . Go to web browser type google and write facebook sharing button click this URL or open this URL.                     Ref URL:...
  • How To Scrape Data From Website Url Using Php.
    Q. why using a Scraping. If we want to get data of another website then using web scraping. It is using a PHP HTML Dom parser library ...
  • How To Install Wordpress in Xampp Server And Wamp Server
      Step 1st  -      Install WampServer or Xampp Server.                                                                               ...
  • Upload Multiple Images to Firebase Storage with Angular
    Step-1 . Create a new Angular Project open command window then write a command.                     #ng new UploadImageApp Step-2 ....

Home

This blog Is very help full for beginner coder,if you want to learn new things definitely this Blog is very
helpful for you guys.

Followers

Contact form

Name

Email *

Message *

Blog

  • Home
  • About Us
  • Privacy Policy
  • Disclaimer
  • Contact Us
  • Terms&Conditions

NewsLetter

Copyright © SoftwareQuery | Powered by softwarequery
Design by ShubhamTiwari | Theme by softwarequery.com | Distributed By softwarequery/