codeigniter: how to redirect after login to current controller (php_self in regular php)
Posted
by krike
on Stack Overflow
See other posts from Stack Overflow
or by krike
Published on 2010-04-16T12:36:11Z
Indexed on
2010/05/14
15:34 UTC
Read the original article
Hit count: 308
Well it's not really a problem but I check if the user exist and log them in and redirect to site/members_area, but I don't want to send the user to a specific page but i want to reload the current controller. So if I login in index/home I would like to be redirected at index/home, how should I proceed?
in regular php I would put in the action to redirect to current page
<?php echo $_SERVER['PHP_SELF']; ?>
This is the code in the framework
function validate_credentials()
{
$this->load->model('membership_model');
$query = $this->membership_model->validate();
if($query) // if the user's credentials validated...
{
$data = array(
'username' => $this->input->post('username'),
'is_logged_in' => true
);
$this->session->set_userdata($data);
redirect('site/members_area'); //<-- this line here should be dynamic
}
else // incorrect username or password
{
$this->index();
}
}
© Stack Overflow or respective owner