I have a blog application that I want a login form in a sidebar. I use Ion Auth library. How do I do that?
I have this in my sidebar view:
<?php echo form_open("blog/login");?>
<p>
<input type="text" name="identity">Username:</>
</p>
<p>
<input type="text" name="password">Password:</>
</p>
<p>
<label for="remember">Remember Me:</label>
<?php echo form_checkbox('remember', '1', FALSE, 'id="remember"');?>
</p>
<p><?php echo form_submit('submit', 'Login');?></p>
<?php echo form_close();?>
But when I click “Login” it goes to different page. I want login function in my blog controller to work behind and staying in home page.
Thanks in advance guys!
It’s difficult to answer without looking at the code, but I’m guessing that you could pass a hidden field in the form with the current URL.
Then, in the blog/login method, after you login the user, you can redirect to the URL received in the hidden field, instead of redirecting to base_url().