Welcome Guest, Not a member yet? Register   Sign In
Issue with form_validation->run and header already sent
#1

[eluser]gmcms[/eluser]
Hi all, I have a peace of code that cannot run without error:

Code:
Cannot modify header information - headers already sent by (output started at ....****..../form_validation_lang.php:1)

The code below:

Code:
public function index()
{
    $this->lang->load('login');
    $data = array();
    $this->form_validation->set_rules('username', 'lang:username', 'required|valid_email');
    $this->form_validation->set_rules('password', 'lang:password', 'required');

    if ($this->form_validation->run() == TRUE)
    {
      // attempt to login
      if($this->securelogin->login($this->input->post('username', TRUE), $this->input->post('password', TRUE))) {
        // success
        redirect(base_url());
      }
      else
      {
        $data = array(
               'error' => 'login_failed'
        );
      }
    }
  $this->load->view('login', $data);
}

I cannot understand how to avoid the problem, even after a lot of search in the forum... each time I remove form_validation->run() the redirect is able to run.
Please what's the issue?
Thanks
Regards
#2

[eluser]Aken[/eluser]
Check that you do not have any white space before the opening <?php tag in your form_validation_lang.php file.
#3

[eluser]gmcms[/eluser]
Hi, there was no white space but an invisible caracter that has been deleted rewriting the open tag.....
Thanks




Theme © iAndrew 2016 - Forum software by © MyBB