After I remove index.php, I enable query string in codeigniter . But I have some trouble with redirect link. Detail , I have login form (login/index) and when login success redirect to "welcome/index" and save email in session .
But when login success only load view of "welcome/index" and wrong link , now link is : "?login/index" And session don't save . Please help me .
Here's my code
Login.php (Controller)
if($this->input->post('email') != '' && $this->input->post('password') != ''){
if ($this->user->CheckLogin($this->input->post('email'),$this->input->post('password')) == true)
{
$this->load->library('session');
$this->session->set_flashdata('email', $this->input->post('email'));
redirect('welcome/index', 'refresh');
}
else
{
$data['error_message'] = '* Email or Password is incorrect';
$this->load->view('login',$data);
}
}else{
$this->load->view('login',$data);
}
Welcome.php (Controller)
class Welcome extends CI_Controller {
public function index()
{
$this->load->model('user');
$this->load->helper('url');
$this->load->library('session');
$data['email'] = $this->session->flashdata('email');
$this->load->view('welcome_message',$data);
}
}
welcome_message.php (View)
<?php
// Cant print email
echo $email;
?>
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
$config['uri_protocol'] = 'QUERY_STRING';
– Mr. ED$config['enable_query_strings'] = FALSE;
or is it set to TRUE – Mr. ED