ItSolutionStuff.com

How to Get form Post Data in Controller Codeigniter?

By Hardik Savani • November 5, 2023
Codeigniter

Here, i will give you simple two way to get form post data in codeigniter 3 project. you can simply get all post data using $this->input->post() and $_POST using simple php stuff.

when i was working on my codeigniter 3 application and i try to get post data using $this->input->post() then i can't get value. i don't know it was not working, but i try to run with virtual domain and with localhost then it was working fine. So if you are trouble with getting form post data then it will help you.

Controller Method:

public function formPost()

{

print_r($this->input->post('name'));

print_r($this->input->post('email'));

print_r($this->input->post());

print_r($_POST['name']);

print_r($_POST['email']);

print_r($_POST);

exit;

}

HTML Form:

<form action="/formPost" method="POST" enctype="multipart/form-data">

<div class="form-group">

<label for="exampleInputEmail1">Email address</label>

<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email" name="email">

</div>

<div class="form-group">

<label for="exampleInputEmail1">Name</label>

<input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter Name" name="name">

</div>

<button class="btn btn-success">Save</button>

</form>

I hope it can help you...

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Codeigniter Create Zip File and Download Example

Read Now →

Codeigniter Create Dynamic Tree View using Treeview JS

Read Now →

Codeigniter Google Recaptcha Form Validation Example

Read Now →

Codeigniter Ajax Pagination using JQuery Example

Read Now →

Codeigniter JQuery Ajax Autocomplete Search using Typeahead

Read Now →

How to Get and Set Config Variables in Codeigniter?

Read Now →

How to implement and use DataTables in CodeIgniter?

Read Now →

Codeigniter Resize Image and Create Thumbnail Example

Read Now →

Codeigniter Ajax Infinite Scroll Pagination Example

Read Now →

Codeigniter Image Upload with Validation Example

Read Now →

How to Get Last Inserted ID in Codeigniter?

Read Now →

Codeigniter Generate PDF from View using Dompdf Example

Read Now →

Codeigniter Ajax CRUD Tutorial Example

Read Now →

Codeigniter Select2 Ajax Autocomplete from Database Example

Read Now →