gpt4 book ai didi

php - IP 地址显示在 CodeIgniter 的表单操作中 http://::1/codeigniter/in html sourcecode

转载 作者:可可西里 更新时间:2023-10-31 22:05:52 25 4
gpt4 key购买 nike

我在 Xampp 上安装了 CI 脚本。目前我正在处理表单,当我点击 html 上的提交时,它什么也没做。

我试过了

echo form_open('verifylogin');
echo form_open();

它在源代码上显示为

<form action="http://::1/codeigniter/verifylogin">
<form action="http://::1/codeigniter/">

分别。

我不明白这个 "http://::1/" 是什么以及如何摆脱它?

最佳答案

如果ip地址显示在form actionurl

  • http://::1/yourproject/
  • http://127.0.0.1/yourproject/

很可能您将基本 url 留空了

/*
|--------------------------------------------------------------------------
| 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/';

并且以 / 结束 url 总是好的

您可能需要在此处为​​您的表单创建路由

application > config > routes.php

CodeIgniter 3: Routing

CodeIgniter 2: Routing


更新:

With CodeIgniter 3 + versions:

当您创建文件时,请记住您必须在文件名仅第一个字母 大写。

有时会发生的是,它可能在小写的本地主机环境中运行良好,但当您转到实时服务器时,有时会抛出错误或提交表单不正确等。

示例:来自 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() {

}

}

代码点火器 Doc's

关于php - IP 地址显示在 CodeIgniter 的表单操作中 http://::1/codeigniter/in html sourcecode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34025305/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com