我在Xampp上安装了CI脚本。目前我正在处理表单,当我点击提交html时,它什么也没做。
我试过
echo form_open('verifylogin');
echo form_open();
它在源代码上显示为
<form action="http://::1/codeigniter/verifylogin">
<form action="http://::1/codeigniter/">
分别
我不明白这个"http://::1/"
是什么以及如何摆脱它?
答案 0 :(得分:28)
如果IP地址显示在表单操作或网址
中http://::1/yourproject/
http://127.0.0.1/yourproject/
您可能已将基本网址留空
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| WARNING: You MUST set this value!
|
| If it is not set, then CodeIgniter will try guess the protocol and path
| your installation, but due to security concerns the hostname will be set
| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise.
| The auto-detection mechanism exists only for convenience during
| development and MUST NOT be used in production!
|
| If you need to allow multiple domains, remember that this file is still
| a PHP script and you can easily do that on your own.
|
*/
$config['base_url'] = '';
现在,在最新版本的codeIgniter中,不建议您将base_url留空。
$config['base_url'] = 'http://localhost/yourproject/';
$config['base_url'] = 'http://www.example.com/';
使用/
您可能需要在此处为表单创建路线
application > config > routes.php
CodeIgniter 3: Routing
CodeIgniter 2: Routing
<强>更新强>
使用CodeIgniter 3 +版本:
创建文件时,您必须在file names
和classes
上使用首字母大写字母。
有时会发生的事情是,它们可能在小写的本地主机环境中工作,但是当您转到实时服务器时某些时候会抛出错误或者不提交正确的表单等。
示例:来自Controllers这同样适用于Models
文件名: Verifylogin.php
<?php
class Verifylogin extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
}
}
文件名: Verify_login.php
<?php
class Verify_login extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
}
}
文件名: verifylogin.php
class verifylogin extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
}
}
文件名: Verify_Login.php
class Verify_Login extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
}
}
Codeigniter Doc's
答案 1 :(得分:8)
转到application / config / config.php set base_url
$config['base_url'] = 'http://localhost/example/';
刷新您的应用
然后::1
错误应该消失。
答案 2 :(得分:0)
转到System / core / Config.php
在第84行设置配置
public function __construct()
{
$this->config =& get_config();
// Set the base_url automatically if none was provided
if (empty($this->config['base_url']))
{
// The regular expression is only a basic validation for a valid "Host" header.
// It's not exhaustive, only checks for valid characters.
if (isset($_SERVER['HTTP_HOST']) && preg_match('/^((\[[0-9a-f:]+\])|(\d{1,3}(\.\d{1,3}){3})|[a-z0-9\-\.]+)(:\d+)?$/i', $_SERVER['HTTP_HOST']))
{
$base_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST']
.substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])));
}
else
{
$base_url = 'http://localhost/';
}
$this->set_item('base_url', $base_url);
}
log_message('info', 'Config Class Initialized');
}
答案 3 :(得分:0)
从网址中删除/
上一个:
<li><a href="/<?=site_url('contacts/create')?>">New Contact</a></li>
之后:
<li><a href="<?=site_url('contacts/create')?>">New Contact</a></li>
答案 4 :(得分:0)
我通过删除重定向中的“ /”解决了这个问题
之前:
public class Field
{
public Guid Guid { get; set; }
public Guid CompanyGuid { get; set; }
}
public class Column
{
public Guid Guid { get; set; }
public Guid CompanyGuid { get; set; }
public Guid TableGuid { get; set; }
public Table Table { get; set; }
}
public class Table
{
public Guid Guid { get; set; }
public Guid CompanyGuid { get; set; }
public List<Column> Columns { get; set; }
}
之后:
header("Location: /index.php?error=TRUE")