Sunday, November 23, 2014

After creating this interface  when i clicked the "Create Your Account" button i want to insert that entered data into database.

According to MVC architecture let's see how to connect view,controller and model.

After creating view we have to call controller.We can use form_open() method to call controller.

According to this interface ,

View :


In line no 14 and 16 it call to the controller.form_open() method you can give your controller name and function that want to execute.As well as make sure to use form_close() method at the end(line no 101).

Now let's see how to implement controller.

Controller:





























Index() :The "index" function is always loaded by default
In here it help to load the register interface.Then after clicking the "Create Your Account Button" it will direct to the createAccount().

First we have to call the model(line no 12).Then we have to create variables to catch the values (line no 13-18).

ex: line 15
$firstname : variable name
$this->input->post('FirstName') :Using post we can catch the value that user entered.We just need to pass the text field name that we named in the view(line no 47).

After we have assigned values to the variable we can use array to pass that data into database.We just need to pass the column name of the database table  and variable that we have created(line no 20-27).Next we have to call the model function to insert data(line no 29).

Next we move on to model,

Model:











In codeigniter it's really easy to insert data we can directly use insert() to pass the data to the database.We just need to pass table name of the database table and array name.

Sunday, October 5, 2014

What is mPDF ?

mPDF is a PHP class which genarates PDF files from UTF-8 encoded HTML.It is based on FPDF and HTML2FPDF ,with a number of enhancements.




First we have to download mpDF.Download mpdf.

Then go to your project folder and put that mpdf file inside  /application/third_party/mpdf.



Then we have to create library file.
Go to /application/libraries/pdf.php





















Add this lines to the pdf.php file.Make sure to give the correct path (line:13) for mpdf.php file.


Then we have to call this library in controller.

This is my controller in here i have defined the logo and other details i have to display in this pdf file as well as you can see how to use database values.

pdfController:












We can set location where we need to genarate  pdf file.

Line 8:$pdfFilePath = FCPATH."downloads\GoBuyAndSell.pdf";

Genarated PDF File:



Wednesday, September 17, 2014

Add PDF,CSV,EXCEL buttons to generate file formats.




By clicking copy,csv,excel,pdf and print you can get table data according to selected button.
First we have to download datatable tools.

Add downloaded files to your project folder.
After that you have to add below links to your view.

View:






next we can create table.In this example I get data from database table and display that data in grid view.

View:












Controller:





Model: 








JavaScript:
In here we have to set the path for copy_csv_xls_pdf.swf file according to your project you have set the path were copy_csv_xls_pdf.swf file is located.















Tuesday, September 16, 2014

Codeigniter validate required field,email and passwords.



If we want to validate required field.we can add required command in view where we need to give input.










As you can see we can use "required" for any kind of input type.
Then we have to call controller and check set the validation rules.





First we have to load the  codeigniter validation Library(Line:157).
Then we can use set_rules() method to set rules.In  this method we can pass three parameters.
  1. The field name - the exact name you've given the form field.
  2. A "human" name for this field, which will be inserted into the error message. For example, if your field is named "user" you might give it a human name of "Username".
  3. The validation rules for this form field.

Validation Rules:
trim: 
It removes white space from the beginning and end of an input string.

required:
Checks that the resulting string is non-empty

valid_email:
Checks that it is a valid email address

xss_clean:
removes malicious data.

matches[]:
The password field must match the password confirmation field.

If user done any mistake we can identify that and simply use set_message() function to display error message. 










Enable/Disable text field according to radio button.

If I select click Personal Account radio button it will display First Name and Last Name fields,

If I select Business Account radio button it will display Company Name field. 


you need to call function when radio button is clicked.
In This example when radio button is clicked radioBtnCheck() will run.












As well as you have group the text fields that are going enable or disable using div id .
According to this example company div id contain company name label and text field.

In this div id it contains first name and last name fields.


After that we have to write java script function to enable or disable the fields. 


In here when radio button on click  it will redirect to this function and check the radio button id,according to selected radio button we can handle what fields we have to enable or disable.

Monday, September 15, 2014

How to create simple registration form



I'm trying to create simple registration form like this and i want do validations for Email,Password and Confirm password fields.

First,we try to create this interface.

View:



  • How to add bootstrap links (line:6-7)
  • How to call controller from view(line:16)
  • How to add radio buttons.(line:23-24)
  • How to add bootstrap button.(line:96)














Friday, September 12, 2014

Codeigniter


Codeigniter is a powerful PHP Framework with a very small footprint,built for PHP coders who need a simple and elegant toolkit to create full featured web applications.



MySQL


MySQL is the world's second most widely used open-source relational database management system (RDBMS).MySQL is a popular choice of database for use in web application.


Bootstrap

Bootstrap is the most popular HTML,CSS and JS framework for developing responsive, mobile first project on the web.


JQuery


jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.


Wednesday, September 3, 2014



What is Framework?

  • Provide general structure of the application.
  • Handle common tasks

Why we use Codeigniter?

1.MVC Architecture



Nowadays, Model View Controller(MVC) is the most popular design pattern in software development.MVC is a way of doing things offers nice code separation and keeps things clean.


  • Model : Encapsulate Business logic,such as interaction with database.(Usually this is the part of your code that retrieves,insert ,update and deletes data in your database).
  • View : Encapsulates the information that is presented to a user. This is the actual web page, RSS feed, or even a part of a page like a header of footer.
  • Controller : Handle the model and view parts of your application to respond to the request.A controller accepts input from the user and instructs the model and a view to perform actions based on that input,it controls the flow of information in the application.

2.No Installation 

  • You can just uploading files to a directory. Codeigniter fits this requirements nicely.No need server modifications to get the framework up and running.just upload the files to your server and your off.

3.Excellent Documentation

  • The company behind Codeigniter (EllisLab), takes a lot of pride in Codeigniter and they have big plans for it and that's why they don’t have a problem in spending the time that is necessary to come up with quality documentation for the user community.

4.Easy to understand

  • Running with Codeigniter the quickest. Codeigniter is also easy to write new libraries, changes the behavior of existing libraries and just change the overall behavior of the framework with little effort.

5.Tools in one package

  • Calender,validation,uploading,e-mails,zip encoding,sessions,unit testing that is just a few of the built in libraries that comes with Codeigniter.It also includes default helpers for things like forms,file handling,arrays,string,cookies,directories and more.