My base_url() is adding more bits into the url than it should be. What is wrong with my setup? I have the helper set up in config.php:
$autoload['helper'] = array('url');
My base_url() is set to: index.php/
So the problem is that when I activate this form:
<h1>sometimes haikus don't make sense refrigerator</h1>
<form action="<?php echo base_url(); ?>welcome/login_submit" method="post">
<label>
email:
<input id="email" name="email" />
</label>
<label>
password:
<input type="password" id="password" name="password" />
</label>
<input type="submit" value="Log me in!" />
</form>
The first time I access it, I'll type in: localhost/CIintranet/ and the the base_url() gets added next so it becomes: localhost/CIintranet/index.php/
I'm trying to program a login logout system though. So if the user login is incorrect, I want it to redirect back to the login page. Here's the code from the controller for that part:
public function login_submit() {
$this->load->model('LoginChecker', 'users');
//$this->load->view('login_submit');
$match = $this->users->authenticate_user( $_POST['email'], $_POST['password'] );
if( $match )
{
$this->load->view('login_submit');
echo "User exists in database!";
}
else
{
$this->load->view('login_form');
echo "<h1>Email or password is wrong, bretheren!</h1>";
}
}
But when it reloads the login_form, it adds another part into the url and the url fails. So the progression is like this:
Page loads to this url:
localhost/CIintranet/
First failed attempt (page still loads properly):
localhost/CIintranet/index.php/welcome/login_submit
Second failed attempt (page fails to load):
localhost/CIintranet/index.php/welcome/index.php/welcome/login_submit
I've been doing some research on this for a bit now and I'm noting a lot of people talking about the htaccess file in relation to this problem but nobody seems to mention specifically what fixes it or how to configure the base_url()
so that it just takes care of this properly. I tried looking at the documentation but perhaps I missed something. I didn't find what I was looking for.
Any ideas?