Codeigniter发布请求重定向到主页

时间:2016-12-28 14:26:53

标签: codeigniter

这里我正在尝试调试其他人的codeigniter应用程序,我意识到所有发布请求都会重定向到主页(基本URL)而不会抛出任何错误消息。可能是什么原因以及如何解决这个问题。提前谢谢.. Lacasera

<form action="controller/method" method="post" accept-charset="utf-8">
  <input type="hidden" name="csrf_test_name" value="9881e8cd803cb06baccb4aafbeb51d70" style="display:none;" />
  <div class="form-group mb-lg">
    <label>Email</label>
    <div class="input-group input-group-icon">
      <input tabindex="1" autofocus name="uname" type="email" class="form-control input-lg" />
      <span class="input-group-addon">
                                        <span class="icon icon-lg">
                                            <i class="fa fa-envelope-o"></i>
                                        </span>
      </span>
    </div>
  </div>

  <div class="form-group mb-lg">
    <div class="clearfix">
      <label class="pull-left">Password</label>
      <a href="#" class="pull-right">Lost Password?</a>
    </div>
    <div class="input-group input-group-icon">
      <input tabindex="2" name="password" type="password" class="form-control input-lg" />
      <span class="input-group-addon">
                                        <span class="icon icon-lg">
                                            <i class="fa fa-lock"></i>
                                        </span>
      </span>
    </div>
  </div>

  <div class="row">

    <div class="col-sm-12 text-right">
      <button type="submit" class="btn btn-success btn-block btn-lg hidden-xs">Sign In <i class="fa fa-sign-in"></i>
      </button>
      <button type="submit" class="btn btn-success btn-block btn-lg visible-xs mt-lg"><i class="fa fa-sign-in"></i> Sign In</button>
    </div>
  </div>
  <p class="text-center">Don't have an account yet? <a href="#">Sign Up!</a>

    </div>
    </div>

2 个答案:

答案 0 :(得分:0)

更改第一行

echo form_open(base_url('index.php/your_controller/'), $attributes);
/**code into the form*/ 
echo form_close()

答案 1 :(得分:0)

首先在控制器构造函数中加载url帮助器,如下所示:

function __construct()
{
$this->load->helper('url');
}

然后提交这样的表格......

<form action="<?php echo base_url('controller_name/method_name'); ?>" method="post" accept-charset="utf-8">
  <input type="hidden" name="csrf_test_name" value="9881e8cd803cb06baccb4aafbeb51d70" style="display:none;" />
  <div class="form-group mb-lg">
    <label>Email</label>
    <div class="input-group input-group-icon">
      <input tabindex="1" autofocus name="uname" type="email" class="form-control input-lg" />
      <span class="input-group-addon">
                                        <span class="icon icon-lg">
                                            <i class="fa fa-envelope-o"></i>
                                        </span>
      </span>
    </div>
  </div>

  <div class="form-group mb-lg">
    <div class="clearfix">
      <label class="pull-left">Password</label>
      <a href="#" class="pull-right">Lost Password?</a>
    </div>
    <div class="input-group input-group-icon">
      <input tabindex="2" name="password" type="password" class="form-control input-lg" />
      <span class="input-group-addon">
                                        <span class="icon icon-lg">
                                            <i class="fa fa-lock"></i>
                                        </span>
      </span>
    </div>
  </div>

  <div class="row">

    <div class="col-sm-12 text-right">
      <button type="submit" class="btn btn-success btn-block btn-lg hidden-xs">Sign In <i class="fa fa-sign-in"></i>
      </button>
      <button type="submit" class="btn btn-success btn-block btn-lg visible-xs mt-lg"><i class="fa fa-sign-in"></i> Sign In</button>
    </div>
  </div>
  <p class="text-center">Don't have an account yet? <a href="#">Sign Up!</a></p><
  </form>