无法连接 Codeigniter
Unable to connect with Codeigniter
这是我的观点login.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Welcome</title>
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/signing.css">
<link rel="stylesheet" href="assets/js/bootstrap.min.js">
</head>
<body>
<div class="container">
<?php echo form_open('Login/validate_credentials',['class'=>'form-signin']); ?>
<h2 class="form-signin-heading">Please sign in</h2>
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" id="inputEmail" name ="username" class="form-control" placeholder="Email address" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" name="password" class="form-control" placeholder="Password" required>
<div class="checkbox">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</form>
</div> ``
这是它的样子
locahost/ci/
当我点击它时显示以下页面,。 apache 日志和访问日志或 mysql 日志中没有错误
错误页面
控制器页面在这里
**
<?php
class Login extends CI_Controller{
public function index(){
$this->load->view('login');
}
public function validate_credentials()
{
$data =array(
$username=$this->input->post('username'),
$password=$this->input->post('password')
);
$this->load->model('Login');
$result=$this->login->validate($data);
if($result==true)
{
redirect('welcome');
}
else{
echo "not found";
}
}
}
?>
配置
$config['base_url'] = 'http://localhost:8080/ci';
$config['index_page'] = 'index.php';
routes.conf
*/
$route['default_controller'] = 'login';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
**
将配置更改为
$config['base_url'] = 'http://localhost/ci';
$config['index_page'] = 'index.php';
您的 CI 设置不正确。根据您的屏幕截图:
第一个屏幕截图 URL:http://localhost/ci
第二张截图URL:http://localhost:8080/ci
更改您的配置:
$config['base_url'] = 'http://localhost/ci';
$config['index_page'] = 'index.php';
这是我的观点login.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Welcome</title>
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/signing.css">
<link rel="stylesheet" href="assets/js/bootstrap.min.js">
</head>
<body>
<div class="container">
<?php echo form_open('Login/validate_credentials',['class'=>'form-signin']); ?>
<h2 class="form-signin-heading">Please sign in</h2>
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" id="inputEmail" name ="username" class="form-control" placeholder="Email address" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" name="password" class="form-control" placeholder="Password" required>
<div class="checkbox">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</form>
</div> ``
这是它的样子
locahost/ci/
当我点击它时显示以下页面,。 apache 日志和访问日志或 mysql 日志中没有错误
错误页面
控制器页面在这里 **
<?php
class Login extends CI_Controller{
public function index(){
$this->load->view('login');
}
public function validate_credentials()
{
$data =array(
$username=$this->input->post('username'),
$password=$this->input->post('password')
);
$this->load->model('Login');
$result=$this->login->validate($data);
if($result==true)
{
redirect('welcome');
}
else{
echo "not found";
}
}
}
?>
配置
$config['base_url'] = 'http://localhost:8080/ci';
$config['index_page'] = 'index.php';
routes.conf */
$route['default_controller'] = 'login';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
**
将配置更改为
$config['base_url'] = 'http://localhost/ci';
$config['index_page'] = 'index.php';
您的 CI 设置不正确。根据您的屏幕截图:
第一个屏幕截图 URL:http://localhost/ci
第二张截图URL:http://localhost:8080/ci
更改您的配置:
$config['base_url'] = 'http://localhost/ci';
$config['index_page'] = 'index.php';