CodeIgniter Forums

Full Version: form redirection
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi guys,

Hope you are all fine.
starting with CI, i have a quick question.
in my controllers, i have contact.php with this code:

PHP Code:
$this->email->from($sender_name,$from);
        
        
$this->email->to('test@test.com');
         
        
$this->email->subject('Contact Us');
        
        
$this->email->message($template);
        
        
$this->email->send();
        
        
redirect('home'); 

my problem is the last line. i have a site in spanigh and english, how can i make rediction to spanish after submit ?
when we are in spanish and vice-versa?

thanks for your help
Well how does your user switch languages normally? If it's just by visiting some endpoint, redirect him to that endpoint (e.g. redirect('home/spanish')Wink.
(04-18-2015, 09:08 AM)gadelat Wrote: [ -> ]Well how does your user switch languages normally? If it's just by visiting some endpoint, redirect him to that endpoint (e.g. redirect('home/spanish')Wink.

The thing is if i do i like this, now the problem come from the other side
if you are in englih part of site and fill form you will be redirect to spanish ...
and yes my users switch languages normally
thanks
The thing is if i do i like this, now the problem come from the other side
if you are in englih part of site and fill form you will be redirect to spanish ...
and yes my users switch languages normally
thanks
You need to determine what language the user is currently using. This is determined by whatever method you used to set the language in the first place. If it's just set by a route in your application, you need to check the relevant portion of the URI. If it's set in the config or the session, you need to retrieve it from there.

Once you know which language the user is currently using, you just send them to the appropriate page.