Php 在代码点火器的xampp服务器中找不到对象?
我是CodeIgniter的新手,我正在开发简单的登录系统,我正在使用xampp,我将CodeIgniter上传到文件夹code/中,下面是mvc中的代码 controller login.phpPhp 在代码点火器的xampp服务器中找不到对象?,php,codeigniter,Php,Codeigniter,我是CodeIgniter的新手,我正在开发简单的登录系统,我正在使用xampp,我将CodeIgniter上传到文件夹code/中,下面是mvc中的代码 controller login.php <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Login extends CI_Controller { public function __construc
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Login extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->library('session');
$this->load->helper('form');
$this->load->helper('url');
$this->load->helper('html');
$this->load->database();
$this->load->library('form_validation');
//load the login model
$this->load->model('login_model');
}
public function index()
{
//get the posted values
$username = $this->input->post("txt_username");
$password = $this->input->post("txt_password");
//set validations
$this->form_validation->set_rules("txt_username", "Username", "trim|required");
$this->form_validation->set_rules("txt_password", "Password", "trim|required");
if ($this->form_validation->run() == FALSE)
{
//validation fails
$this->load->view('login_view');
}
else
{
//validation succeeds
if ($this->input->post('btn_login') == "Login")
{
//check if username and password is correct
$usr_result = $this->login_model->get_user($username, $password);
if ($usr_result > 0) //active user record is present
{
//set the session variables
$sessiondata = array(
'username' => $username,
'loginuser' => TRUE
);
$this->session->set_userdata($sessiondata);
redirect("index");
}
else
{
$this->session->set_flashdata('msg', '<div class="alert alert-danger text-center">Invalid username and password!</div>');
redirect('login/index');
}
}
else
{
redirect('login/index');
}
}
}
}?>
密码
打开应用程序/config/config.php
并设置基本url()
。例如:$config['base\u url']='http://localhost/code/';代码>
在/code
文件夹(应用程序和系统文件夹所在的位置)下创建.htaccess
文件,如下所示:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
在\code中创建.htaccess
文件\
作为
在config/config.php中
$config['base_url'] = 'http://localhost/code';
希望它能对您有所帮助。我得到了如下所示的相同错误。我正在使用php/codeigniter。我已经定义了$config['base\u url']='http://localhost/******';代码>在我的配置文件中。但它仍然显示出同样的问题
找不到对象!在此服务器上找不到请求的URL。如果
您手动输入了URL。请检查拼写,然后重试。
如果您认为这是服务器错误,请联系网站管理员
我怎样才能解决这个问题
步骤1:1我检查了httpd.conf文件。导入了mod_rewrite
步骤2:检查文件是否位于实际位置
步骤3:检查重定向或锚标记中的拼写错误
步骤4:选中application/config.php文件中的$config['base\u url']
变量
步骤5:选中application/config.ph文件中的$config['index\u page']
变量。这是我真正的问题。我将其设置为空白,并且我的mod_rewrite
模块出现问题。当我放入$config['index\u page']='index.php'
它开始为我工作。在配置文件中设置你的基本url我将基本url设置为localhost添加你的项目名称也添加了localhost/code,但它显示找不到对象和错误404如果你使用的是CI3版本,你的文件和类名应该有首字母大写。它正在工作,但在我输入login之后deatils[link]显示404错误您必须在routes.php文件中添加所有页面(包括帖子URL)。它将修复此错误。打开application/config/routes.php并添加如下行:$route['some_url']='Controller_name/function_name'代码>为您自己的系统编辑此示例。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteEngine On
RewriteBase /code/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
$config['base_url'] = 'http://localhost/code';