EllisLab text mark
Advanced Search
     
Redirecting to route from controller method
Posted: 10 November 2012 09:31 AM   [ Ignore ]
Joined: 2012-10-02
5 posts

I have a controller name “HomeController” where I have the following methods:

<?php
class HomeController extends CI_Controller
{
  public function __construct()
  {
      parent::__construct();
      $this->load->helper(‘url’);
      $this->load->helper(‘captcha’);
      $this->load->helper(‘html’);
      $this->load->library(‘form_validation’);
      $this->load->library(‘cart’);
      $this->load->model(‘DatabaseModel’,‘dm’,TRUE);
  }
  public function ShipDetails()
  {
      $this->load->view(‘ShippingDetails’);
  }
  public function UserType()
  {
      $this->load->view(“UserType”);
      if($this->input->post(‘nxt’))
      {
        $radioval=$this->input->post(‘Radio’);
        switch($radioval)
        {
          case 1:
              $this->UserLogin();
              break;
          case 2:
              //echo “Guest User”;
              //redirect(‘tmp’);
              redirect(’/HomeController/ShipDetails/’);
              break;
        }
      }
  }
Now what I want is to redirect to the page named “ShippingDetails.php” (which is written inside the method “ShipDetails()) via router.
if I am using the above code the url is showing the following:
http://localhost/Sandip/CodeIgniter/HomeController/ShipDetails ” i,e., the controller class as well as controller method.I just wanna hide the Class & method in the URL. How can I do this? Please help.Novice in PHP-CI.
Is it possible to redirect to “routes” from controller method,if so how?

 
Posted: 10 November 2012 06:05 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2009-04-15
454 posts

yes, you can redirect to routes from the routes.php config. you just call the route.

as a matter of fact, if you had tried that before coming here to ask a question about it, you would already know that. wink

 Signature 

Code By Jeff

Mahana Messaging Library

Problem with your query? Did you run

$this->db->last_query(); 

before you came to the forums for help?