IP地址显示在与CodeIgniter http:// :: 1 / codeigniter / in html源代码的窗体操作中 [英] IP address is showing in form action with CodeIgniter http://::1/codeigniter/ in html sourcecode
问题描述
我在Xampp上安装了CI脚本。目前我正在处理表单,当我点击html提交时,它什么都不做。
我尝试了
echo form_open('verifylogin');
echo form_open();
它在源代码上显示为
< form action =http:// :: 1 / codeigniter / verifylogin>
< form action =http:// :: 1 / codeigniter />
。
理解这个http:// :: 1 /
是什么以及如何摆脱它?
如果ip地址显示在表单操作或网址
-
http:// :: 1 / yourproject /
-
http:// 127.0.0.1/yourproject /
您可能已离开基本网址空白
/ *
| ------------------------ --------------------------------------------------
|基本网址URL
| ------------------------------------------ --------------------------------
|
|您的CodeIgniter根的URL。通常这将是您的基本URL,
|带有斜杠:
|
| http://example.com/
|
|警告:您必须设置此值!
|
|如果没有设置,CodeIgniter将尝试猜测协议和路径
|您的安装,但由于安全问题,主机名将设置为
|到$ _SERVER ['SERVER_ADDR'](如果可用),否则为localhost。
|自动检测机制仅仅为了方便起见,在
|中存在开发,不得用于生产!
|
|如果你需要允许多个域,记住这个文件仍然是
|一个PHP脚本,你可以轻松地做到这一点。
|
* /
$ config ['base_url'] ='';
现在天最近的codeIgniter版本,不建议你留下你的base_url空白。
-
$ config ['base_url'] ='http:// localhost / yourproject /';
-
$ config ['base_url'] ='http://www.example.com/';
并且总是好的结束url与 /
您可能需要在此创建表单的路线
application> config> routes.php
CodeIgniter 3: /www.codeigniter.com/user_guide/general/routing.htmlrel =nofollow>路由
CodeIgniter 2: 路由
更新:
使用CodeIgniter 3 + p>
在创建文件时,您必须在首字母 >文件名
和类
。
有时会发生的情况是,它可能会在小写的localhost环境中正常工作,但是当您转到活动服务器有时将抛出错误或不提交表单正确等。
这是有效的
文件名: Verifylogin.php
<?php
pre>
class Verifylogin extends CI_Controller {
public function __construct(){
parent :: __ construct();
}
public function index(){
}
}
这是有效的
: Verify_login.php
<?php
pre>
class Verify_login extends CI_Controller {
public function __construct(){
parent :: __ construct();
}
public function index(){
}
}
这是不有效
档案名称: verifylogin.php
class verifylogin extends CI_Controller {
pre>
public function __construct(){
parent :: __ construct();
}
public function index(){
}
}
这是不有效
文件名: Verify_Login.php
class Verify_Login extends CI_Controller {
pre>
public function __construct(){
parent :: __ construct();
}
public function index(){
}
}
Codeigniter 文档
I have the CI script installed on Xampp. Currently I am working on forms and when I click on submit on html, it does nothing.
I tried
echo form_open('verifylogin'); echo form_open();
It show on sourcecode as
<form action="http://::1/codeigniter/verifylogin"> <form action="http://::1/codeigniter/">
respectively.
I don't understand what this
"http://::1/"
is and how to get rid of it?解决方案If ip address is displayed in form action or url
http://::1/yourproject/
http://127.0.0.1/yourproject/
Chances are you have left the base url blank
/*
|--------------------------------------------------------------------------
| 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'] = '';
Now days in latest versions of codeIgniter it is not recommend that you leave your base_url blank.
$config['base_url'] = 'http://localhost/yourproject/';
$config['base_url'] = 'http://www.example.com/';
And is always good to end url with /
You may need to create routes for your form here
application > config > routes.php
CodeIgniter 3: Routing
CodeIgniter 2: Routing
Update:
With CodeIgniter 3 + versions:
When you create a file remember you will have to have first letter ONLY upper case on file names
and classes
.
What will happen sometimes is that it all may well work in a localhost environment with lower case but when you go to a live server some times will throw errors or not submit forms correct etc.
Example: From Controllers This also applies to Models
This is valid
File name: Verifylogin.php
<?php
class Verifylogin extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
}
}
This is valid
File name: Verify_login.php
<?php
class Verify_login extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
}
}
This is not valid
File name: verifylogin.php
class verifylogin extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
}
}
This is not valid
File name: Verify_Login.php
class Verify_Login extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
}
}
Codeigniter Doc's
这篇关于IP地址显示在与CodeIgniter http:// :: 1 / codeigniter / in html源代码的窗体操作中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!