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 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择
  • ¥15 部分网页页面无法显示!
  • ¥15 怎样解决power bi 中设置管理聚合,详细信息表和详细信息列显示灰色,而不能选择相应的内容呢?
  • ¥15 QTOF MSE数据分析
  • ¥15 平板录音机录音问题解决