Get a Form’s GET and POST Data in CodeIgniter

When a form is submitted in CodeIgniter, the information is automatically sent to the controller specified in the form action attribute. However, you may sometimes need to access this data directly in your controller code. For instance, you might want to process data from a form that doesn’t use the default submit button or that uses AJAX.

To do this, you can call $this->input->get() and $this->input->post() of CodeIgniter or PHP’s built-in global variables $_GET and $_POST. These functions will return an array of all the data that was sent in the request. You can then access individual data items by their name, just as you would with any other associative array.

These functions are also useful for processing data that isn’t necessarily from a form submission, such as query string parameters or JSON-encoded data.

<?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(); ?>
$name= $this->input->get('name');
$description = $this->input->get('description');

$password = $_GET['password'];
$country = $_GET['country'];
$id = $this->input->post('id');
$validationCode = $this->input->post('validationCode');

$token = $_POST['token'];
$hash = $_POST['hash'];

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.