Welcome Guest, Not a member yet? Register   Sign In
Storing a request URL
#2

[eluser]Twisted1919[/eluser]
The easiest way i can see here is to use the http referer .
You need to use a MY_Controller in order to achieve this .
so you will have something like :
Code:
class MY_Controller extends Controller{

   public $back_url ;

   function __construct()
   {
     parent::Controller();
     $this->back_url = (!empty($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']) !== FALSE) ? $_SERVER['HTTP_REFERER'] : site_url()
   }

}

//Then, your controller
class Process_form extends MY_Controller{
    
    function process()
    {
      if(not empty $_POST and other validations + database submissions)
      {
       redirect($this->back_url);
      }
    }

  }


Of course you can always store the last url into your session but is a bit more complex, for what you need, the above example should be enough .


Messages In This Thread
Storing a request URL - by El Forum - 07-24-2010, 10:36 AM
Storing a request URL - by El Forum - 07-24-2010, 11:11 AM
Storing a request URL - by El Forum - 07-24-2010, 11:20 AM
Storing a request URL - by El Forum - 07-24-2010, 11:24 AM
Storing a request URL - by El Forum - 07-24-2010, 12:21 PM
Storing a request URL - by El Forum - 07-24-2010, 12:28 PM
Storing a request URL - by El Forum - 07-24-2010, 12:34 PM
Storing a request URL - by El Forum - 07-24-2010, 03:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB