Creating a layout in codeigniter :-
Default codeigniter doesn’t have any of templating features you have add or create layout manually for your codeigniter site. there is lot’s of way to do this but i am sharing some simple code to create layout in codeigniter. we can easily use templating in codeigniter and arrange layout for site. so we need to divide our pages in some parts and load them at once when page loading.
Let’s see how we can use templating in codeigniter.
How to use custom form validation in codeigniter :-
codigniter have most of form validations inbulit but sometime we need to apply our own or custom validation on form fields like mobile, email etc. In codeigniter we can easily apply our custom validation to form. there is a simple process to apply custom validation in codeigniter we can apply custom form validation using rules or using libarary. let’s see how to create custom validation in codeigniter there are two method for this :-
Connecting multiple database in codeigniter :-
Sometimes we need to use two or multiple database for a single site. If you need to connect to more than one database simultaneously. codeigniter provide an easy handy feature to connect multiple database. for this we need to add some config of databases and load the db instance. we need to set only PCONNECT(persistent connection) to set TRUE/FALSE. Below we will see how to connect multiple databse in codeigniter with direct loading db object in controller/model and how to connect multiple database in codeigniter using library.
How to create pagination in codeigniter :-
A another feature why use framework for site that we can easily create pagination in codeigniter it’s own pagination library with less code and less time.
Pagination :- When we are working with thousand or millions of record or working with bunch of data and need to show them then we need to divide into more pages to show all data in parts. to prevent millions of records show in a single page. records showing in parts is a good functionality to prevent query fails and long time process.For this we need to use pagination (refers to links that allows you to navigate from page to page).
We can easily create pagination in codeigniter with it’s own library. codeigniter provide an easy and customizable pagination. below we will see how to use pagination in codeigniter with showing total rows or record count and use query string with pagination in codeigniter.
Redirect to ssl in codeigniter :-
HTTPS :- Full name is (hyper text transfer protocol secure). It’s a extended or you can say secure version of the HTTP(hyper text transfer protocol). If you have https enabled on your server you will get a lock icon in address bar of browser.
For encryption of data it’s used ssl (secure sockets layer) certificates to install on your server. Most uses of https to securely transmit data with ssl.
So most of sites need ssl or https url. we can easily manage redirection to https url in codeigniter using hooks. it’s a one more good feature of CI. We need to create some lines of code to get ssl url or redirect to https url in codeigniter. Default codeigniter not have this type of functionality so we need to force redirect to ssl url. below we will see how to use ssl redirect with codeigniter.
How to remove index.php from url codeigniter :-
If we need a clean url in codeigniter. we need to remove index.php from url. Default you will get index.php in url in codeigniter cause index.php file included with url in codeigniter. so url looks like :-
codeigniter provide easy way for url rewrite functionality to get clean url or remove index.php from url in codeigniter. we can easily done by using .htaccess some of config file changes. after remove index.php from url you will see controller name in url like “http://example.com/controller”.
We need to remove index.php from url so we can get clean url for our codeigniter site and url not looks odd or to get a user friendly or seo friendly url.