Friday, 18 March 2016

how to create session using ajax in codeigniter

Create Session Using Ajax

We would discuss about to create seesion using codeigniter. Here we have to done on the function to do that codeigniter framework. The given fields like username, password, date of birth, email, phone number those are validation here.

Then we have to move instalization to create file in controller folder. Then given below coding to copy and paste there. That function name is add_register. In that function we do the form validation and store form data to the particular variable. Then it should pass to the library function.

 <?php  
 //controller  
       public function add_register()  
       {  
            //form validation  
           $this->form_validation->set_rules('user_name','Username','trim|required|xss_clean|is_unique[user.user_name]');  
           $this->form_validation->set_rules('dob','Date Of Birth','trim|required|xss_clean');  
           $this->form_validation->set_rules('user_email','Email','trim|required|valid_email|xss_clean|is_unique[user.user_email]');  
           $this->form_validation->set_rules('ph_no','Phone Number','trim|required|numeric|xss_clean');  
           $this->form_validation->set_rules('user_password','Password','trim|required|xss_clean');  
           if($this->input->is_ajax_request()) { $data['ajax']=TRUE; } else { $data['ajax']=FALSE; }  
           $data['response']='';  
           if($this->form_validation->run()===FALSE)  
           {  

Wednesday, 10 February 2016

Download The excel file using php

Download the Excel File using Php

The given code is used to download the excel file using php or codeigniter. Here just normally given to the php code.
  • First header describe to content type to extract the application text like which type of document.
  • Second header is to give the content description to attach the file format for we need it.
  • Next header is pragma  to display the type to format.
  • last one is display the file expires day to given in that attribute.
  • finally we create the design and data for the files. that depends on the file format. in excel we must using tables because then we get sufficient content format.


 header("Content-type: application/octet-stream");  
           header("Content-Disposition: attachment; filename=excelfile.xls");