Category Archives: CodeIgniter

codeigniter

codeigniter 4 image upload example tutorial

In this codeigniter 4 image upload example tutorial I will show you how to upload image fine in codeigniter 4. In this tutorial you will learn to upload image file in codeigniter 4. I will also show you how to validate upload image into folder and then save it into database. In this tutorial before saving image into database we will validate image and then save it into directory using. Before uploading the image we will perform server side validation. In this article we will create a simple example to upload image in codeigniter 4.

codeigniter 4 image upload example tutorial

In this step by step tutorial I will demonstrate you with example how to upload image file in codeigniter 4. Please follow the instruction given below:

  • Install Codeigniter
  • Basic Configurations
  • Create a Database in table
  • Connect to Database
  • Create Controller and Model
  • Create Views Files
  • Run The Application

Install Codeigniter 4

Download or install the latest version of CodeIgniter 4

Basic Configurations

Now, we need to setup some codeigniter basic configurations in your project as following.

Create a Database in table

Now you need to create some database tables in your codeigniter application database. Please use the following sql query to create database tables.

Connect to Database

Now, lets create a MySQL database and connect it with codeigniter application. After creating database we need to set database credential in application’s app/Config/Database.php file.

app/Config/Database.php

Create Controller and Model

In this step we will create a “Student.php” controller file and the “StudentModel.php” model file. Please paste the below code in corresponding file.

app/Models/StudentModel.php

Create Views Files

Now, in this step we will create a view file and put following code in it.
app/views/add.php

Run The Application

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

Codeigniter 4 cURL POST Request Example Tutorial

In this Codeigniter 4 cURL POST Request Example Tutorial I’ll show you how to post form data using curl post request method in codeigniter. In this tutorial you will learn to make curl POST request in codeigniter. You will also learn to make curl request with header authentication in codeigniter. In this article I will share example to how to use and make curl request in codeigniter.

PHP Codeigniter cURL POST Request example

In this example we will be implementing codeigniter controller method to make curl POST  request. We will be setting curl url and curl request parameters for POST request in controller method.

PHP Codeigniter cURL POST Request with header authentication

In this example we will be implementing codeigniter controller method to make curl POST  request with header authentication. We will be setting curl url and curl request parameters for POST request in controller method.

Codeigniter 4 cURL PUT Request Example Tutorial

In this Codeigniter 4 cURL PUT Request Example Tutorial I’ll show you how to create curl PUT request in codeigniter 4. In this tutorial you will learn to make curl PUT request in codeigniter. You will also learn to make curl request with header authentication in codeigniter. In this article I will share example to how to use and make curl request in codeigniter.

PHP Codeigniter cURL PUT Request example

In this example we will be implementing codeigniter controller method to make curl PUT request. We will be setting curl url and curl request parameters for PUT request in controller method.

PHP Codeigniter cURL PUT Request with header authentication

In this example we will be implementing codeigniter controller method to make curl PUT request with header authentication. We will be setting curl url and curl request parameters for PUT request in controller method.

Codeigniter 4 cURL Get Request Example Tutorial

In this Codeigniter 4 cURL Get Request Example Tutorial I’ll show you how to create curl GET  request in codeigniter 4. In this tutorial you will learn to make curl GET request in codeigniter. You will also learn to make curl request with header authentication in codeigniter. In this article I will share example to how to use and make curl request in codeigniter.

Codeigniter 4 cURL Get Request Example Tutorial

In this example we will be implementing codeigniter controller method to make curl get request. We will be setting curl url and curl request parameters for GET request in controller method.

How to get the current URL in Codeigniter

In this How to get the current URL in Codeigniter tutorial I will show you how to get current url in codeigniter. In this tutorial you will learn to get current application url in codeigniter. In this article I will share example to get current url in codeigniter application.

get the current URL in Codeigniter

In this step by step tutorial I will demonstrate you with example how to get current url in codeigniter. Please follow the instruction given below –

Get current URL in codeigniter

In Codeigniter we have a builtin url helper library. In codeigniter url helper allow us to get the current URL using the current_url() method. Below is the example to get the current url using the current_url() method in codeigniter.

Example:-

how to get URL segment in codeigniter

In codeigniter the segment() method is used to get the url segments from the url. Below is the example to retrieve the url segments using the segment() method in codeigniter.

Example:-

Get Current Controller Method Name in codeigniter

In codeigniter the fetch_method() method is used to get the current controller method’s name . Below is the example to get the current controller method name using the fetch_method() method.

Example:-

Autocomplete Textbox in CodeIgniter using Typeahead

In this Autocomplete Textbox in CodeIgniter using Typeahead Js, I will show you how to create a dynamic database driven ajax jquery autocomplete using typeahead js in codeigniter. In this tutorial we will create a dynamic search dropdown autocomplete which will fetch options from database table using bootstrap typeahead js.

The Typeahead JS is a jquery plugin, it is used to create dynamic autocomplete input with several options. In this example you will learn how to implement typeahead autocomplete in codeigniter.

Autocomplete Textbox in CodeIgniter using Typeahead

In this step by step tutorial I will demonstrate how to create a dynamic database driven ajax jquery autocomplete using typeahead js in codeigniter. Please follow the instruction given below:

Step 1: Download Codeigniter
Step 2: Basic Configurations
Step 3: Create a Database in table
Step 4: Connect to Database
Step 5: Create Controller and Model
Step 6: Create Views Files
Step 7: Run The Application

Download Codeigniter

First of all you need to download the latest version of Codeigniter 4.

Basic Configurations

Now, we need to setup some codeigniter basic configurations in your project as following.

Create a Database in table

Now you need to create some database tables in your codeigniter application database. Please use the following sql query to create database tables.

Connect to Database

Now, lets create a MySQL database and connect it with codeigniter application. After creating database we need to set database credential in application’s app/Config/Database.php file.

app/Config/Database.php

Create Controller and Model
In this step we will create a “Student.php” controller file and the “StudentModel.php” model file. Please paste the below code in corresponding file.

app/Models/StudentModel.php

Codeigniter Multiple Files Upload Example

In this Codeigniter Multiple Files Upload Example, I’ll show you how to upload multiple image file in codeigniter. In this codeigniter multiple image upload example, I’ll show you how to validate and upload multiple image file into folder and then save it into database. In this tutorial before saving multiple image into database we will validate image and then save it into directory. Before uploading the image we will validate the image. After successfully uploading multiple images into the folder and saving it in database we will display success message on the screen.

Codeigniter Multiple Files Upload Example

In this step by step tutorial I’ll demonstrate how to upload multiple files in codeigniter with validation. Please follow the steps given below:

Step 1:Create Upload Directory
Step 2:Create The Controller
Step 3:Create The Model
Step 4:Create The View

Create Upload Directory

First of all we have to create assets/uploads/ directory.

Create The Controller

Now, we will create a Multipleimage.php controller. Open Multipleimage.php and put the following code in it.

Create The Model

Lets create the Image_model.php model file as following.

Create The View

Now we will create the image.php view file and put the following code in it.

Multiple database connection in codeigniter

In this Multiple database connection in codeigniter tutorial I will show you how to connect multiple database in codeigniter single application. In this tutorial you will learn to use multiple database connection in codeigniter. You will also learn how to connect multiple database in single codeigniter application.

Multiple database connection in codeigniter

In this tutorial I will share following example to connect or use multiple database in codeigniter application. In this example we will be defining two arrays in application/config/database.php file as following –

application/config/database.php

Now we can access different database connection as following –

how to get last inserted id in codeigniter example

In this how to get last inserted id in codeigniter example tutorial I will show you how to get last inserted id in codeigniter. In this tutorial you will learn to get last inserted id after codeigniter insert query. In this article I will share example to show you how to get last inserted record id on insert query in codeigniter.

how to get last inserted id in codeigniter example

In this step by step tutorial I will demonstrate you with example how to get last inserted id in codeigniter. Below is example to show you to get last record id from MySQL using CodeIgniter.

Example:-

Codeigniter 4 Google Autocomplete Address Search Box Tutorial

In this Codeigniter 4 Google Autocomplete Address Search Box Tutorial, I’ll show you how to integrate Address or location Autocomplete using Google Autocomplete in CodeIgniter 4. In this tutorial you will learn to implement google autocomplete in codeigniter 4.

Google Autocomplete

Google autocomplete widget is used to display suggestions for places, address and location as soon as the user starts typing in the given input box.

Codeigniter 4 Google Autocomplete Address Search Box Tutorial

In this codeigniter 4 google autocomplete tutorial I’ll demonstrate you step by step process to integrate google autocomplete in codeigniter 4 project. Pleasae follow the instructions given below:

  • Create Codeigniter Project
  • CI Error Handling
  • Get Google Maps API Key
  • Connect to Database
  • Create Controller
  • Create Route
  • Add Autocomplete Widget in View
  • Run CI Application

Create Codeigniter Project

First of all we need to create a fresh codeigniter project, download and install codeigniter through composer using following command:

CI Error Handling

In this step we will change display_errors prop’s value to 1 in app/Config/Boot/production.php for error debugging,

app/Config/Boot/production.php

Get Google Maps API Key

Now, we need to get Google API key to enable the communication between client and Google server. Now follow the instructions given below to get Google API Key:

  • Visit Google Cloud Platform.
  • Click on the project dropdown at the top to create the project.
  • Click APIs & Services > Credentials.
  • Now, click on Create Credentials > API key.
  • Copy google API and store in some text file.
  • Now we need to enable few services, so click on Credentials > “Enable APIs and Services”, additionally enable “Maps JavaScript API” and “Places API” services.