I am new on codeigniter. I want to display multipe view on different pages. I create a page on which I create an edit button. I want that when I click on edit button I rediect on another page. How can I do that?
Here is my code:
class Edit extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function edit()
{
$this->load->helper('url');
if($this->input->post('edit') == True)
{
redirect('edit');
}
}
}
View 1: (Where your link is present)
<?php echo anchor('Edit/edit', 'Edit Value'); // Here Edit is your controller and edit is the function name. ?>
And in Edit controller modify it like this:
class Edit extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function edit()
{
$this->load->helper('url');
if($this->input->post('edit') == True)
{
//redirect('edit'); //Do not use this as this line will call the same function again.
$this->load->view('edit_view'); // where edit_view.php is present in your views directory.
}
}
}
Hope this helps.