PHPMailer in CodeIgniter

In a previous post I talked about how to use the library PHPMailer to send emails from our website without having our own mail server running on the machine. This time we will go a step further and explain how to integrate this library in our CodeIgniter project and not die in the attempt.

The first thing we do, if we have not done it yet, will be to download the library. Once we unzip the library, we can rename the folder named PHPMailer and move it to the folder /system/application/libraries (for CodeIgniter 1.7.3 or previous) or to the folder /application/libraries/ (for CodeIgniter 2.0 or later) in our CodeIgniter application. Once we did it so, we can start to implement our own library, which will be in charge of including PHPMailer into our application. To do this we have to create a new PHP file in the CodeIgniter’s library directory called my_phpmailer.php. In this file we will write the following code:

CodeIgniter and JSON with jQuery

In this post, we are going to talk about how to receive data in CodeIgniter via JSON, using for that the JavaScript framework jQuery. But before that, we need to clarify a bit what is JSON and what is it used for.

What is JSON? What is it used for?

JSON stands for JavaScript Object Notation. So, it is a way of writing the properties of objects in JavaScript so that they can be sent between client and server and vice versa. This format is very light due to its internal structure, which is quite human readable, and it is very easy to process by machines. While there is a debate about which format is better, if XML or JSON, for sending and receiving data via AJAX, there is a large community of developers who bet on JSON as the AJAX communication technology that will prevail in the future, alleging among other things that being lighter than XML the communication between client and server is faster. […]