[eluser]condoace[/eluser]
I have some files which require logging in/sessions. I am trying to redirect a user to the original page they went to before they were directed to login page - but my problem is that instead of redirecting to the view file it redirects to the form action - i.e. the controller method..
My code is:
Controller method called from form action:
Code:
function validate()
{
$this->load->library('session');
$this->load->model('membership_model');
$email = $this->input->post('email');
$password = $this->input->post('password');
$return = $this->membership_model->check_user($email,$password);
if($return)
{
$data = array(
'email' => $email,
'password' => $password,
'logged_in' => TRUE
);
$this->session->set_userdata($data);
$template = array('main_content' => uri_string());
$this->load->view('include/template',$template);
}
else
{
$this->index();
}
}
My form
Code:
<div class="signup"/>
<?php echo form_open('login/validate');?>
<fieldset>
<legend class="signup_leg">Email</legend>
<div class="signup_field"><input type="text" name="email" id="email" class="signup_field" value="<?php echo set_value('email')?>"/>
</div>
</fieldset>
<fieldset>
<legend class="signup_leg">Password</legend>
<div class="signup_field"><input type="password" name="password" id="password" class="signup_field" value="<?php echo set_value('password');?>"/>
</div>
</fieldset>
<fieldset>
<div class="signup_field"><input type="submit" name="submit" id="submit" class="signup_field"/>
</div>
</fieldset>
<?php echo form_close();?>
</div>