How to redirect page in codeigniter?

Member

by lew , in category: Third Party Scripts , 2 months ago

How to redirect page in codeigniter?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by jasen_gottlieb , 2 months ago

@lew 

You can redirect a page in CodeIgniter using the redirect() function provided by CodeIgniter's URL helper. Here's an example of how you can do it:

  1. Load the URL helper in your controller:
1
$this->load->helper('url');


  1. Redirect to a specific URL:
1
redirect('controller/method');


In this example, controller is the name of the controller and method is the name of the method you want to redirect to. You can also redirect to a specific URL:

1
redirect('http://example.com');


  1. You can also redirect to the previous page by using the redirect() function with no arguments:
1
redirect();


This will redirect the user back to the previous page they were on.


That's it! You have successfully redirected a page in CodeIgniter using the redirect() function.