-->



Saturday, October 10, 2015

Codeigniter--Inserting data into database

After the Cross-site Scripting Application, Now we are going to learn about Inserting data into the database.

1.  Rename your Codeigniter folder as "inserigniter".
2.  Now configure your files.Go to C:\xampp\htdocs\insertigniter\application\config  and select  autoload.php and make changes as follows.

          $autoload['libraries'] = array('database','xmlrpc');
          $autoload['helper'] = array('url', 'file','form');

3.  Here xmlrpc is  a way for two computers to communicate over the internet using XML.
4.  Next select database.php and make changes as follows.

           $db['default']['hostname'] = 'localhost';
           $db['default']['username'] = 'root';
           $db['default']['password'] = '';
           $db['default']['database'] = 'company_db';
           $db['default']['dbdriver'] = 'mysql';

5.  Create a new file view.php in C:\xampp\htdocs\insertigniter\application\views.Here is the code. Just copy and paste it in your file.    

                                                         view.php




6.  Create a new file vcontroller.php in C:\xampp\htdocs\insertigniter\application\controllers.Here is the code. Just copy and paste it in your file.

                                                      vcontroller.php




7.  Create a new file model.php in C:\xampp\htdocs\insertigniter\application\models.Here is the code. Just copy and paste it.

                                                  model.php

                      

8.Create a css folder in C:\xampp\htdocs\insertigniter and create a file named styles.css. Just copy and paste the following code.

                                                     styles.css

                             


9.  For the database part, just copy and paste in your database.

           

10. Now redirect to http://localhost/insertigniter/index.php/vcontroller.
11. You should get the following screen.

                               



That's it!,In the next tutorial,we will be learning about Captcha-generated Form.

No comments:

Post a Comment