Category: CodeIgniter
-
Flashdata
While building web application, we need to store some data for only one time and after that we want to remove that data. For example, to display some error message or information message. In PHP, we have to do it manually but CodeIgniter has made this job simple for us. In CodeIgniter, flashdata will only…
-
Session Management
When building websites, we often need to track user’s activity and state and for this purpose, we have to use session. CodeIgniter has session class for this purpose. Initializing a Session Sessions data are available globally through the site but to use those data we first need to initialize the session. We can do that by…
-
Form Validation
Validation is an important process while building web application. It ensures that the data that we are getting is proper and valid to store or process. CodeIgniter has made this task very easy. Let us understand this process with a simple example. Example Create a view file myform.php and save the below code it in application/views/myform.php. This page…
-
Sending Email
Sending email in CodeIgniter is much easier. You also configure the preferences regarding email in CodeIgniter. CodeIgniter provides following features for sending emails − Email class has the following functions to simplify the job of sending emails. S.N. Syntax Parameters Return Return Type 1 from($from[, $name = ”[, $return_path = NULL]]) $from (string) − “From” e-mail address$name (string) −…
-
File Uploading
Using File Uploading class, we can upload files and we can also, restrict the type and size of the file to be uploaded. Follow the steps shown in the given example to understand the file uploading process in CodeIgniter. Example Copy the following code and store it at application/view/Upload_form.php. Copy the code given below and store…
-
Error Handling
Many times, while using application, we come across errors. It is very annoying for the users if the errors are not handled properly. CodeIgniter provides an easy error handling mechanism. You would like the messages to be displayed, when the application is in developing mode rather than in production mode as the error messages can…
-
Libraries
The essential part of a CodeIgniter framework is its libraries. It provides a rich set of libraries, which indirectly increase the speed of developing an application. The system library is located at system/libraries. All we need to do is to load the library that we want to use. The library can be loaded as shown…
-
Working with Database
Like any other framework, we need to interact with the database very often and CodeIgniter makes this job easy for us. It provides rich set of functionalities to interact with database. In this section, we will understand how the CRUD (Create, Read, Update, Delete) functions work with CodeIgniter. We will use stud table to select, update, delete,…
-
Configuration
After setting up the site, the next thing that we should do is to configure the site. The application/config folder contains a group of files that set basic configuration of your site. Configuring Base URL The base URL of the site can be configured in application/config/config.php file. It is URL to your CodeIgniter root. Typically,…
-
Basic Concepts
Controllers A controller is a simple class file. As the name suggests, it controls the whole application by URI. Creating a Controller First, go to application/controllers folder. You will find two files there, index.html and Welcome.php. These files come with the CodeIgniter. Keep these files as they are. Create a new file under the same path named “Test.php”. Write the…