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

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

<?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(); ?>

Table of Contents


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

$text = $_GET['name'];
$isTrim = $_GET['trim'];


$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 *

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.