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");  

Monday, 16 November 2015

Convert HTML to PDF using php

Convert HTML to PDF using php



  1. First of all we need the supporting file so please download TCPDF
  2. Just create pdf.php file and copy the below code.
  3. The supporting file locate as the same folder or you just modify the link in above code as require_once(dirname(__FILE__).'/tcpdf/tcpdf.php');.


 <?php   
 $url=parse_url($_SERVER['HTTP_REFERER']);  
 // Include the main TCPDF library (search for installation path).  
 require_once(dirname(__FILE__).'/tcpdf/tcpdf.php');  
 // create new PDF document  
 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);  
 // set document information  
 $pdf->SetCreator(PDF_CREATOR);  
 $pdf->SetAuthor('Sakthivel');  
 $pdf->SetTitle('talentcoders.blogspot.com Download pdf');  
 $pdf->SetSubject('Downloadable pdf');  
 $pdf->SetKeywords('PDF for invoice');  
 // set default header data  
 /*$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));*/  
 /*$pdf->setFooterData(array(0,64,0), array(0,64,128));*/  
 // set header and footer fonts  

Wednesday, 4 November 2015

Upload the image using AJAX

How to upload the image using AJAX

Step 1 : First of all need to download the plugin from the following link. Plugins
Step 2 : Then create the front end design to copy the below code.
 <link href="<?php echo asset_path ?>plugins/ajax_upload/assets/css/style.css" rel="stylesheet" />  
 <form class="form-horizontal" id="upload" method="post" action="<?php echo admin_path; ?>add_post/upload" enctype="multipart/form-data">  
 <input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" id="csrf_token" value="<?php echo $this->security->get_csrf_hash(); ?>" />  
 <div class="form-group mar_top20">  
   <label for="" class="col-sm-3 control-label">Cover Image</label>  
   <div class="col-sm-7">  
    <div class="cover">  
         <div class="drop">  
                     <a>Browse</a>  
                     <input type="file" name="upl" />  
                </div>  
                <ul>  
                </ul>  
                </div>  
   </div>  
   </div>   
    </form>  
    <link href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css" rel="stylesheet" />  
   <link href="<?php echo asset_path ?>plugins/datepicker/datepicker3.css" rel="stylesheet" />  
 <script src="//cdnjs.cloudflare.com/ajax/libs/s

Saturday, 24 October 2015

Send mail with attachment using PHP-Mailer Function

How to send mail with attachment using PHP-Mailer Function

Step 1 : Just the copy and paste the below code on mail.php and use it.
Just download Php-Mailer Function
 <?php  
 include('base.php');  
 $home=new main();  
 require_once('plugin/PHPMailer-master/class.phpmailer.php');  
 if(isset($_POST['submit']))  
 {       
      $fname=$_POST['fname'];  
      $phno=$_POST['phno'];  
      $email=$_POST['email'];  
      $college=$_POST['college'];  
           $path="SACMS/resume/";  
                $valid_formats = array("doc", "docx", "pdf");  
                $name = $_FILES['resume']['name'];  
                $size = $_FILES['resume']['size'];  
                if(strlen($name))