I have an issue while login . when i click on a link and if i am not loggedin than it will redirect me to login page and after success login it should redirect me requested url but it redirect me to profile page. here is my view file:
<!--Left cols-->
<?php error_reporting(0);?>
<div class="col-lg-8 col-sm-8 col-md-8">
<div class="reg-form">
<h2>Member's Login</h2>
<title>Login</title>
<form method="post" action="<?php echo base_url();?>index.php/register_step1/login">
<div class="row">
<label for="name">Email</label>
<span><i class="icon-name"></i><input type="email" placeholder="example@gmail.com" required id="name" name="email"/></span>
</div>
<div class="row">
<label for="pass">Your Password</label>
<span><i class="icon-pass"></i><input type="password" placeholder="*************" id="pass" required name="password"/></span>
</div>
<!--input type="hidden" name="redirurl" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" /-->
<div class="row">
Forgot Password <a href="">click here</a> / <a href="">Register</a> new user
</div>
<div class="row">
<input type="submit" value="Login" name="submit"/>
</div>
</form>
</div>
</div>
<?php $this->load->view("home_template/rightbar");?>
And this is my controller :
public function login(){
$this->load->model("User_model");
$this->load->library('user_agent');
if(isset($_POST["submit"])){
//$url = $this->input->post("redirurl");
$data = $this->User_model->login();
if($data){
foreach($data as $dta){
$id = $dta->id;
$email = $dta->email;
}
$session_array = array("id"=>$id,"email"=>$email);
$this->session->set_userdata("logged_by_login",$session_array);
redirect("profile");
}
}
else{
}
$data["main_content"] = "login_view";
$this->load->view("home_template/template",$data);
}