Home » CodeIgniter

CodeIgniter

HTML to PDF Conversion in CodeIgniter

A number of PHP libraries to convert HTML page to PDF file. After a lot of research and googling find TCPDF PHP library to convert HTML page to PDF file for client requirement. TCPDf PHP library quite easy to integrate with CodeIgniter. The implementation of the code. Download the TCPDF library code Download it from TCPDF website http://www.tcpdf.org/ Now create ...

Read More »

Send SMS using CodeIgniter

$url = 'http://smsgateways.com/api/sendmsg.php?' . http_build_query([ 'user' => '', 'pass' => '', 'sender' => '', 'phone' => '', 'text' => '', 'priority' => 'ndnd', 'stype' => 'normal' ]); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch);

Read More »

Export Database using codeigniter

Database Utility Class : CodeIgniter PHP script to download mysql db-codeigniter,Backup MySQL database with CodeIgniter public function dbexport() { $this->load->dbutil(); $prefs = array( 'format' => 'zip', 'filename' => 'my_db_backup.sql' ); $backup =& $this->dbutil->backup($prefs); $db_name = 'backup-on-'. date("Y-m-d-H-i-s") .'.zip'; $save = 'public/uploads/'.$db_name; $this->load->helper('file'); write_file($save, $backup); $this->load->helper('download'); force_download($db_name, $backup); }

Read More »

How to print Codeigniter upload error

if you want to display errors on upload functionality in codeigniter. Use the following function if($this->upload->do_upload('image')) { $contentimagedata=$this->upload->data(); $descdata['image']=$contentimagedata['file_name']; }else { $error = array('error' => $this->upload->display_errors()); print_r($error); }

Read More »

CodeIgniter Disallowed Key Characters

website development

Somewhere in the html form you simply missed the opening quote  of input name attribute(s). Example <input type=”text” name=last_name“> Just find and use the right syntax for happy coding. You can find the code for tracking disallowed characters are in system/core/input.php file function _clean_input_keys($string) { if (! preg_match("/^[a-z0-9:_/-]+$/i", $string)) { exit('Disallowed Key Characters.+'. $string)); } return $string; }

Read More »

csrf exception url codeigniter

Add the following line to application/config/config.php file.   $config['csrf_exclude_uris'] = array('controller 1','controller 2','controller3/method 1','controller3/method 2');   system/core/Security.php Modify the public function csrf_verify() function in Security.php public function csrf_verify() { // If it's not a POST request we will set the CSRF cookie if (strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST') { return $this->csrf_set_cookie(); } // this IF statement is the fix // Check if URI ...

Read More »

How to Check Expired Sessions using jQuery Ajax and PHP

We can achieve using the php and ajax.The following ajax call execute in every 10 seconds to check the status of session.If it expired the user redirected to seesionout page. Ajax call in every 10 seconds   var check_current_session; function CheckForCurrentSession() { var strSession=”check_current_session=true”; jQuery.ajax({ type: “GET”, url: “check_current_session.php”, data: strSession, cache: false, success: function(result){ if(result== “Y”) { alert(‘Your session ...

Read More »

Codeigniter utf-8 character input data save issue

Codeigniter have utf-8 character input data save issue in some hosting servers like Etisalat. system/core/Utf8.php have function to detect illegal char in input data(post/get). In some cases utf-8 char is consider as illegal and save function will fail. For avoid data saving issue do the following in clean_string() function of Utf8.php at line 85. $str = !mb_detect_encoding($str, 'UTF-8', TRUE) ? ...

Read More »

Codigniter arabic language issue in etisalat hosting server

Codeigniter have utf-8 character input data save issue in some hosting servers like Etisalat. system/core/Utf8.php have function to detect illegal char in input data(post/get). In some cases utf-8 char is consider as illegal and save function will fail. For avoid data saving issue do the following in clean_string() function of Utf8.php at line 85. $str = !mb_detect_encoding($str, 'UTF-8', TRUE) ? ...

Read More »

Add multiple products to Paypal Cart with One Click

Paypal is a payment gateway used in number of websites in world wide.We can post shopping cart info  to paypal from the website The following code shows the syntax of code used to post multiple cart items to paypal <form id=”paypalform” action=”https://www.paypal.com/cgi-bin/webscr” method=”post” name=”paypal_auto_form”> <input name=”rm” type=”hidden” value=”2″ /> <input name=”cmd” type=”hidden” value=”_cart” /> <input name=”upload” type=”hidden” value=”1″ /> <input ...

Read More »