Friday, January 19, 2018

Codeigniter is a MVC framework, which has its own functionality to insert a form data to mysql database table. Now by using ajax post method we will insert the codeigniter form data to mysql database table.
Now we will create a database table as branddetails, which looks as below.






After creating the table, now we will create a view to insert the
Form data to branddetails table.

After creating view, now let’s talk about Ajax post method, here I created a JavaScript function branddetails. Here Serialize () method is used to create URL encoded text string from input form values, and these values can be used in URL query string when making Ajax post request, now write ajax post method as below.

Now store encoded text string to variable paramstr, now use jquery ajax post method to send form request using url.
Create branddetailsinsert method under dashboard controller in codeigniter. Let’s look into the code once to insert the form data from ajax post method.

In the above controller we are calling model class insertbranddetails() method to insert form data, as you know codeigniter uses model, view and controller architecture. Now let’s check model class methods in below code.

As you know when array is passed into codeigniter insert function
It will execute the method and inserts data into branddetails database table, and returns the stored variable $insertdet to controller method, finally controller function check’s weather the data inserted using if condition ,if its inserts return result as “successful” else return “not successful”.
This returned value is passed to ajax post method success function and displays alert message as successful.

Thanks for reading this article.

Tags: , ,
I am Saritha Reddy, a Remote codeigniter,Angularjs Developer. I have 4+ years of strong experience in designing, implementing, Programming and delivering advanced XAMPP ( Apache, MySQL and PHP) Web applications development. I am an Indian national and based Andhra Pradesh,Hyderabad. In addition to providing custom programming and design, I also have extensive experience with Open Source technologies to keep costs down and get websites running with as little fuss and wait as possible.

6 Comments

google api tutorial December 9, 2015 at 3:14 am

Pretty! This has been an incredibly wonderful post. Thanks for providing this information.

RodgerTLemay July 15, 2016 at 8:18 pm

This article is genuinely a pleasant one it helps
new net users, who definitely are wishing for blogging.

HesterPNieto August 19, 2016 at 10:16 pm

All things are very open using a precise explanation of the
issues. It was actually truly informative. Your internet site is extremely helpful.
Thank you for sharing!

ChangUPortis August 25, 2016 at 3:20 pm

It’s a pity you don’t use a donate button! I’d definitely donate for this superb
blog! I guess right now i’ll be happy with bookmarking and adding
your RSS feed to my Google account. I anticipate new updates and may speak about
this site with my Facebook group. Talk soon!

AntwanDElsen August 26, 2016 at 6:05 pm

I’m really impressed with the writing skills as well as together with the layout on your weblog.
Is this a paid theme or do you modify it yourself?
Anyway continue the excellent quality writing,
it can be rare to discover a great blog such
as this one nowadays.

GerryJCumins September 13, 2016 at 1:08 am

excellent put up, very informative. I wonder why the opposite experts of this sector don’t notice this.
You should continue your writing. I’m sure, you possess an incredible readers’ base
already!

Leave a Comment