Codeigniter escape_str() function

This function will escape all data, regardless of type. $sql = " INSERT INTO table (name) VALUES(" . $this->db->escape_str( $name) . " ) " ; $this->db- >query($sql) ;
Continue reading…

Enjoyed this post? Share it!

 
 

Create a hashing plugin in PHP codeigniter

We will start by creating a new file inside the system/application/plugins/ folder, called hash_pi.php. Save the following code into the file. The logic is to split the password by half and use it as the point to insert the salt in encrypting the password. <?php function hash_password( $password, $salt) { $password_length = length($password) ; $split_at […]
Continue reading…

Enjoyed this post? Share it!

 
 

Twitter_oauth class in codeigniter

The following code loads the oAuth library and sets up a set of variables for us to store certain information in. <?php require_once(APPPATH.’libraries/twitter/OAuth.php’) ; class Twitter_oauth { var $consumer; var $token; var $method; var $http_status; var $last_api_call; } ?> $consumer— it is used to store the credentials for our application keys and the user tokens. […]
Continue reading…

Enjoyed this post? Share it!

 
 

Checking the values of form post in PHP Codeigniter

$name = $this->input->post(’ name’ ) ; $email = $this- >input->post( ‘ email’ ) ; $subj ect = $this->input->post( ‘ subject’ ) ; $message = $this->input->post( ‘ message’ ) ; if( empty($name) OR empty( $email) OR empty($subject) OR empty($message) ) { show_404 ("The form submitted left fields blank, all fields are required. Please go back and […]
Continue reading…

Enjoyed this post? Share it!

 
 

Send email in codeigniter with debugging information

$this->load->library(’email’ ) ; $this->email- >from(’ you@example. com’ , ‘ Your Name’ ) ; $this->email- >to(’someone@example. com’ ) ; $this->email- >cc(’another@person. com’ ) ; $this->email- >bcc(’theboss@example. com’ ) ; $this->email- >subject(’ Email Test’ ) ; $this->email- >message(’ This is a simple test we wrote for the email class. ‘ ) ; $this->email- >send() ; echo $this->email- […]
Continue reading…

Enjoyed this post? Share it!

 
 

Profiling benchmarks in codeigniter

If you want your benchmarks to be available to the Profiler Class then you will need to set your benchmarks up in pairs. These pairs should end with _start and _end, but be otherwise identically named. Example: $this->benchmark->mark( ‘ first_mark_start’ ) : // something happens $this->benchmark->mark( ‘ first_mark_end’ ) ; $this->benchmark->mark( ‘ second_mark_start’ ) ; […]
Continue reading…

Enjoyed this post? Share it!

 
 

Setting multiple benchmarks using codeigniter

With the Benchmark Class, you can set multiple benchmarks and calculate the time difference between any of them. $this->benchmark->mark( ‘one’ ) ; // something happens here $this->benchmark->mark( ‘two’ ) ; // something else happens here $this->benchmark->mark( ‘three’ ) ; echo $this->benchmark->elapsed_time(’one’ , ‘two’ ) ; echo $this->benchmark->elapsed_time(’two’ , ‘three’ ) ; echo $this->benchmark->elapsed_time(’ one’ , […]
Continue reading…

Enjoyed this post? Share it!

 
 

Setting a benchmark in codeigniter

We can set a benchmark in codeigniter by setting the starting point, setting the ending point and use a function to show the elapsed time. Example code: $this->benchmark->mark( ‘ start’ ) ; // code executes here.. $this->benchmark->mark( ‘ end’ ) ; echo $this->benchmark->elapsed_time(’ start’ , ‘ end’ ) ; The names start and end are […]
Continue reading…

Enjoyed this post? Share it!