问题描述
我在 Xampp 上安装了 CI 脚本.目前我正在处理表单,当我点击 html 上的提交时,它什么也不做.
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.
我试过了
echo form_open('verifylogin');
echo form_open();
它在源代码中显示为
<form action="http://::1/codeigniter/verifylogin">
<form action="http://::1/codeigniter/">
分别.
我不明白这个 "http://::1/"
是什么以及如何摆脱它?
I don't understand what this "http://::1/"
is and how to get rid of it?
推荐答案
如果ip地址显示在form action或url
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 留空.
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/';
用 /
您可能需要在此处为您的表单创建路由
You may need to create routes for your form here
application > config > routes.php
CodeIgniter 3: 路由
CodeIgniter 2: 路由
更新:
使用 CodeIgniter 3 + 版本:
当您创建文件时,请记住您必须在 file names
和 classes
上使用仅第一个字母大写.
When you create a file remember you will have to have first letter ONLY upper case on file names
and classes
.
有时会发生的情况是,这一切都可以在 localhost 环境中以小写字母运行,但是当您转到实时服务器时有时会抛出错误或提交表单不正确等.
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
文件名:验证登录.php
<?php
class Verifylogin extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
}
}
这是有效的
文件名:Verify_login.php
This is valid
File name: Verify_login.php
<?php
class Verify_login extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
}
}
这无效有效
文件名: verifylogin.php
This is not valid
File name: verifylogin.php
class verifylogin extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
}
}
这无效有效
文件名:Verify_Login.php
This is not valid
File name: Verify_Login.php
class Verify_Login extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
}
}
Codeigniter 文档
Codeigniter Doc's
这篇关于IP 地址在 HTML 源代码中使用 CodeIgniter http://::1/codeigniter/以表单操作显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!