How to Get Form GET and POST Data in CodeIgniter’s Controller

In this article, we will discuss how to get and post data from a controller in CodeIgniter and provide some examples of how to use the GET and POST methods to get and post data from a controller.

Following are 2 simple ways to get input data from a form in CodeIgniter.

Table of Contents


<?php  echo form_open(''); ?>
<div class="form-group">
	<textarea class="form-control" name="text" placeholder="Your text..." rows="10"></textarea>
<div class="form-group">
	<input type="checkbox" name="trim"> Trim text?
<div class="form-group text-center">
	<input type="submit" name="submit" class="btn btn-primary" value="Submit">
<?php echo form_close(); ?>

Query GET Data

$text = $this->input->get('name');
$isTrim = $this->input->get('trim');
$text = $_GET['name'];
$isTrim = $_GET['trim'];

Query POST Data

$text = $this->input->post('name');
$isTrim = $this->input->post('trim');
$text = $_POST['name'];
$isTrim = $_POST['trim'];

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.