I am new to CI and would normally try to pass some information back to a login page like the following...
public function authenticate()
{
$this->load->model('User_model', '', true);
if ($this->User_model->authenticate($this->input->post('username'), $this->input->post('password')))
{
$this->session->set_userdata('loggedin', true);
header('Location: /');
}
else
{
header('Location: /sessions/login/error?='.'1');
}
}
And then on the login page use a _GET.
So how would I best go about this in CodeIgniter?
First of all, using GET for sensitive data like email/password is a general no-no. Bad practice all the way.
But the answer to your question is here - http://www.codeigniter.com/userguide3/libraries/input.html
$this->input->get('username')is equal to$_GET['username']. You might use$this->input->get('username', TRUE)to escape some malicious code.And
$this->input->post('username')is equal to$_POST['username']. This is what I advise you to use (it requires modification of your HTML though)