Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Codeigniter登录404_Php_Codeigniter_Login_Frameworks_Http Status Code 404 - Fatal编程技术网

Php Codeigniter登录404

Php Codeigniter登录404,php,codeigniter,login,frameworks,http-status-code-404,Php,Codeigniter,Login,Frameworks,Http Status Code 404,我刚开始使用CI,我正在尝试登录。我读了一些教程,然后试着自己做一个,但没有效果。当我尝试登录时,收到一个错误: 在此服务器上找不到请求的URL/Helpor/login\u controller/going\u in 我试过很多东西,但都没用 这是我的登录视图中的登录表单: <form action="<?php echo base_url();?>login_controller/going_in" method="post" name="going_in"> <

我刚开始使用CI,我正在尝试登录。我读了一些教程,然后试着自己做一个,但没有效果。当我尝试登录时,收到一个错误:

在此服务器上找不到请求的URL/Helpor/login\u controller/going\u in

我试过很多东西,但都没用

这是我的登录视图中的登录表单:

<form action="<?php echo base_url();?>login_controller/going_in" method="post" name="going_in">
<?php if(! is_null($msg)) echo $msg;?>
<table style="font-size: 30px;">
    <tr>
        <td>Username: </td>
        <td><input type="text" size="45" name="username" style="background-color: #C5D2F5;"/></td>
    </tr>
    <tr>
        <td>Password: </td>
        <td><input type="password" size="45" name="password" style="background-color: #C5D2F5;"/></td>
    </tr>
    <tr>
        <td></td>
        <td><input type="submit" value="Login" style="border-width: 2px; height: 40px; width: 120px; font-family: Calibri; font-size: 22px; background-color: #FEFEFF;"></td>
    </tr>
    <tr>
        <td><a href="?lang=en"><img src="<?= base_url() ?>assets/img/United_Kingdom(Great_Britain).png"/></a>&nbsp;
            <a href="?lang=nl"><img src="<?= base_url() ?>assets/img/Netherlands.png"/></a>
        </td>
    </tr>
</table>
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class login_controller extends CI_Controller{

function __construct(){
    parent::__construct();
}

public function index($msg = NULL){
    $this->load->database();
    $this->load->helper('url');
    $data['msg'] = $msg;
    $this->load->view('login', $data);
}

public function going_in(){
    // Load the model
    $this->load->model('login_model');
    // Validate the user can login
    $result = $this->login_model->validate();
    // Now we verify the result
    if(! $result){
        // If user did not validate, then show them login page again
        $msg = '<font color=red>Invalid username and/or password.</font><br />';
        $this->index($msg);
    }else{
        // If user did validate, 
        // Send them to members area
        redirect('user');
    }        
  }
}
?>
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login_model extends CI_Model{
function __construct(){
    parent::__construct();
}

public function validate(){
    // grab user input
    $username = $this->security->xss_clean($this->input->post('username'));
    $password = $this->security->xss_clean($this->input->post('password'));

    // Pre ping the query
    $this->db->where('username', $username);
    $this->db->where('password', $password);

    // Run the query
    $query = $this->db->get('users');
    //check for results
    if($query->num_rows == 1)
    {
        //create session data
        $row = $query->row();
        $data = array(
                'id' => $row->ID,
                'username' => $row->Username,
                'level' => $row->Level,
                'validated' => true
                );
        $this->session->set_userdata($data);
        return true;
    }
    return false;
  }
}
?>
$config['base_url'] = 'http://localhost/Helptor/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
索引页面:

<form action="<?php echo base_url();?>login_controller/going_in" method="post" name="going_in">
<?php if(! is_null($msg)) echo $msg;?>
<table style="font-size: 30px;">
    <tr>
        <td>Username: </td>
        <td><input type="text" size="45" name="username" style="background-color: #C5D2F5;"/></td>
    </tr>
    <tr>
        <td>Password: </td>
        <td><input type="password" size="45" name="password" style="background-color: #C5D2F5;"/></td>
    </tr>
    <tr>
        <td></td>
        <td><input type="submit" value="Login" style="border-width: 2px; height: 40px; width: 120px; font-family: Calibri; font-size: 22px; background-color: #FEFEFF;"></td>
    </tr>
    <tr>
        <td><a href="?lang=en"><img src="<?= base_url() ?>assets/img/United_Kingdom(Great_Britain).png"/></a>&nbsp;
            <a href="?lang=nl"><img src="<?= base_url() ?>assets/img/Netherlands.png"/></a>
        </td>
    </tr>
</table>
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class login_controller extends CI_Controller{

function __construct(){
    parent::__construct();
}

public function index($msg = NULL){
    $this->load->database();
    $this->load->helper('url');
    $data['msg'] = $msg;
    $this->load->view('login', $data);
}

public function going_in(){
    // Load the model
    $this->load->model('login_model');
    // Validate the user can login
    $result = $this->login_model->validate();
    // Now we verify the result
    if(! $result){
        // If user did not validate, then show them login page again
        $msg = '<font color=red>Invalid username and/or password.</font><br />';
        $this->index($msg);
    }else{
        // If user did validate, 
        // Send them to members area
        redirect('user');
    }        
  }
}
?>
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login_model extends CI_Model{
function __construct(){
    parent::__construct();
}

public function validate(){
    // grab user input
    $username = $this->security->xss_clean($this->input->post('username'));
    $password = $this->security->xss_clean($this->input->post('password'));

    // Pre ping the query
    $this->db->where('username', $username);
    $this->db->where('password', $password);

    // Run the query
    $query = $this->db->get('users');
    //check for results
    if($query->num_rows == 1)
    {
        //create session data
        $row = $query->row();
        $data = array(
                'id' => $row->ID,
                'username' => $row->Username,
                'level' => $row->Level,
                'validated' => true
                );
        $this->session->set_userdata($data);
        return true;
    }
    return false;
  }
}
?>
$config['base_url'] = 'http://localhost/Helptor/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
Uri\u协议:

<form action="<?php echo base_url();?>login_controller/going_in" method="post" name="going_in">
<?php if(! is_null($msg)) echo $msg;?>
<table style="font-size: 30px;">
    <tr>
        <td>Username: </td>
        <td><input type="text" size="45" name="username" style="background-color: #C5D2F5;"/></td>
    </tr>
    <tr>
        <td>Password: </td>
        <td><input type="password" size="45" name="password" style="background-color: #C5D2F5;"/></td>
    </tr>
    <tr>
        <td></td>
        <td><input type="submit" value="Login" style="border-width: 2px; height: 40px; width: 120px; font-family: Calibri; font-size: 22px; background-color: #FEFEFF;"></td>
    </tr>
    <tr>
        <td><a href="?lang=en"><img src="<?= base_url() ?>assets/img/United_Kingdom(Great_Britain).png"/></a>&nbsp;
            <a href="?lang=nl"><img src="<?= base_url() ?>assets/img/Netherlands.png"/></a>
        </td>
    </tr>
</table>
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class login_controller extends CI_Controller{

function __construct(){
    parent::__construct();
}

public function index($msg = NULL){
    $this->load->database();
    $this->load->helper('url');
    $data['msg'] = $msg;
    $this->load->view('login', $data);
}

public function going_in(){
    // Load the model
    $this->load->model('login_model');
    // Validate the user can login
    $result = $this->login_model->validate();
    // Now we verify the result
    if(! $result){
        // If user did not validate, then show them login page again
        $msg = '<font color=red>Invalid username and/or password.</font><br />';
        $this->index($msg);
    }else{
        // If user did validate, 
        // Send them to members area
        redirect('user');
    }        
  }
}
?>
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login_model extends CI_Model{
function __construct(){
    parent::__construct();
}

public function validate(){
    // grab user input
    $username = $this->security->xss_clean($this->input->post('username'));
    $password = $this->security->xss_clean($this->input->post('password'));

    // Pre ping the query
    $this->db->where('username', $username);
    $this->db->where('password', $password);

    // Run the query
    $query = $this->db->get('users');
    //check for results
    if($query->num_rows == 1)
    {
        //create session data
        $row = $query->row();
        $data = array(
                'id' => $row->ID,
                'username' => $row->Username,
                'level' => $row->Level,
                'validated' => true
                );
        $this->session->set_userdata($data);
        return true;
    }
    return false;
  }
}
?>
$config['base_url'] = 'http://localhost/Helptor/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
更新

地图应用程序中的My.htaccess文件如下所示

全盘否定

更新2

这是我的文件夹结构:

localhost/helptor
 -application
   -controllers
     -index.html
     -login_controller.php
     -user.php
   -models
     -login_model.php
     -index.html
   -views
     -.htaccess
     -index.html
     -login.php
     -user.php
   .htaccess
   index.html
 -assets
 -system
 index.php

快速阅读CodeIgniter文档()可以找到他们为URL推荐的
.htaccess
语法:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

试试这个,看看这是否能解决问题。

快速阅读CodeIgniter文档()可以找到这个
。htaccess
他们推荐的URL语法:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

尝试此操作,看看是否可以解决问题。

如果您在www/helptor中工作,请尝试以下操作:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /helptor/index.php/$1 [L]

将来部署到另一台服务器时,应记住删除此“helptor”字符串

如果您在www/helptor中工作,请尝试以下操作:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /helptor/index.php/$1 [L]

将来部署到另一台服务器时,应记住删除此“helptor”字符串

我知道现在有点晚了,但这对我来说很有效

您应该将Apache AllowOverride策略设置为all。 这是我为该站点添加到我的.conf中的内容

<Directory "/var/www/yoursite">
    Options -Indexes
    AllowOverride All
</Directory>

选项-索引
允许超越所有

我知道这有点太晚了,但这对我来说很有效

您应该将Apache AllowOverride策略设置为all。 这是我为该站点添加到我的.conf中的内容

<Directory "/var/www/yoursite">
    Options -Indexes
    AllowOverride All
</Directory>

选项-索引
允许超越所有

请仅将基本路径更改为“/Helptor/”htaccess(或类似)是否正确?能否发布htaccess文件请清空.htaccess文件一段时间,将“我的基本路径”更改为“仅”//Helptor/”,但仍然会出现相同的错误。请仅将基本路径更改为“/Helptor/”是htaccess(或类似)吗正确吗?您可以发布htaccess文件吗?请暂时清空您的.htaccess文件。将我的基本路径更改为仅“/Helptor/”,但仍会收到相同的错误。尝试了它,仍会收到错误。但是我的.htaccess文件在应用程序文件夹中,我必须把它放在视图文件夹中吗?你需要把
.htaccess
放在与Codeigniter
index.php
文件相同的文件夹中。添加了我的文件夹结构,所以
.htaccess
文件在你的
Helpor
文件夹的根目录中?是的,但我删除了它,因为当我按下登录按钮时它转到了来自wamp的localhost页面,这很奇怪。它现在仅位于“视图”文件夹和“应用程序”文件夹中。已尝试,但仍然收到错误。但是我的.htaccess文件在应用程序文件夹中,我必须把它放在视图文件夹中吗?你需要把
.htaccess
放在与Codeigniter
index.php
文件相同的文件夹中。添加了我的文件夹结构,所以
.htaccess
文件在你的
Helpor
文件夹的根目录中?是的,但我删除了它,因为当我按下登录按钮时它转到了来自wamp的localhost页面,这很奇怪。它现在仅位于“视图”文件夹和“应用程序”文件夹中。