douli4337 2012-11-24 17:39
浏览 144

Codeigniter - 在此服务器上找不到请求的URL

For the last couple of days my frustration has grown to new heights. Im trying to do a simple login system in codeigniter and I cant get it to work properly.

when submitting the login form I get the following error:

The requested URL /wishlist/login_controller/login was not found on this server.

Here is the form:

<form method="post" action="<?php echo base_url()?>login_controller/login">
<input type="text"placeholder="E-mail" id="email" name="email">
<input type="password" placeholder="Password" id="password" name="password">
<input class="btn btn-primary span2" type="submit" id="sign-in" value="Sign In">
</form>

Here is my login function in login_controller:

class Login extends CI_Controller {


function login() {

    $data['error'] = 0;

    if ($_POST) {

        $this->load->model('user_model');
        $email = $this->input->post('email', true);
        $password = $this->input->post('password', true);
        $user = $this->user_model->login($email, $password);

        if (!$user) {
            $data['error'] = 1;
        } else {
            $this->session->set_userdata('userID', $user['userID']);
            $this->session->set_userdata('firstname',    $user['firstname']);

            redirect(base_url().'admin_controller');

        }
    }

    $this->load->view('home_view');
}

I'm using wampserver on localhost. Here is the url that it tries to access: localhost/wishlist/login_controller/login

Am I correct in assuming that the first part after base_url() is the controller and the second part is the function in that controller?

A couple of settings from the config folder.

$config['base_url'] = '';
$config['index_page'] = 'index.php';
$route['default_controller'] = "site_controller";
  • 写回答

4条回答 默认 最新

  • duanjiao8007 2012-11-24 17:44
    关注

    please rename your controller from

    class Login extends CI_Controller {
    

    to

    class Login_Controller extends CI_Controller {
    

    then you can do

    <form method="post" action="<?php echo site_url('login_controller/login'); ?>">
    <input type="text"placeholder="E-mail" id="email" name="email">
    <input type="password" placeholder="Password" id="password" name="password">
    <input class="btn btn-primary span2" type="submit" id="sign-in" value="Sign In">
    </form>
    

    then use this:

    $config['base_url'] = 'http://localhost/wishlist/';
    $config['index_page'] = '';
    

    and htacees:

    RewriteEngine On
    RewriteBase /wishlist
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /wishlist/index.php/$1 [L]
    

    if it's not enought switch config.php file at line:

    | URI PROTOCOL
    |--------------------------------------------------------------------------
    |
    | This item determines which server global should be used to retrieve the
    | URI string.  The default setting of 'AUTO' works for most servers.
    | If your links do not seem to work, try one of the other delicious flavors:
    |
    | 'AUTO'            Default - auto detects
    | 'PATH_INFO'       Uses the PATH_INFO
    | 'QUERY_STRING'    Uses the QUERY_STRING
    | 'REQUEST_URI'     Uses the REQUEST_URI
    | 'ORIG_PATH_INFO'  Uses the ORIG_PATH_INFO
    |
    */
    $config['uri_protocol'] = 'AUTO';
    

    i use AUTO maybe you need QUERY_STRING or REQUEST_URI option

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器