douzhuo8871 2014-04-16 19:57
浏览 51
已采纳

Base_url()是否在我的网址中添加了不必要的细分?

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?

  • 写回答

2条回答 默认 最新

  • doulun1915 2014-04-17 02:02
    关注

    Can you try setting the base_url to /index.php/? So it has the forward slash at the front too?

    Failing that, please try: http://localhost/CIintranet/index.php/

    It's usually the simple things!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 MATLAB代码补全插值
  • ¥15 Typegoose 中如何使用 arrayFilters 筛选并更新深度嵌套的子文档数组信息
  • ¥15 前后端分离的学习疑问?
  • ¥15 stata实证代码答疑
  • ¥50 husky+jaco2实现在gazebo与rviz中联合仿真
  • ¥15 dpabi预处理报错:Error using y_ExtractROISignal (line 251)
  • ¥15 在虚拟机中配置flume,无法将slave1节点的文件采集到master节点中
  • ¥15 husky+kinova jaco2 仿真
  • ¥15 zigbee终端设备入网失败
  • ¥15 金融监管系统怎么对7+4机构进行监管的