IP 地址在 html 源代码中的 CodeIgniter http://::1/codeigniter/表单操作中显示 [英] IP address is showing in form action with CodeIgniter http://::1/codeigniter/ in html sourcecode

查看:25
本文介绍了IP 地址在 html 源代码中的 CodeIgniter http://::1/codeigniter/表单操作中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我试过了

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

它在源代码上显示为

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

分别.

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

解决方案

如果ip地址显示在form actionurl

  • 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 总是好的

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

应用程序>配置>路由文件

CodeIgniter 3: 路由

CodeIgniter 2: 路由

<小时>

更新:

<块引用>

使用 CodeIgniter 3 + 版本:

当您创建文件时请记住,文件名classes 必须只有第一个字母 大写.

有时会发生的情况是,这一切都可以在小写的本地主机环境中正常工作,但是当您转到实时服务器时有时会抛出错误或不正确提交表单等.>

示例:来自控制器 这也适用于模型

这是有效的

文件名:Verifylogin.php

<小时>

这是有效的

文件名:Verify_login.php

<小时>

这是无效有效

文件名: verifylogin.php

class verifylogin extends CI_Controller {公共函数 __construct() {parent::__construct();}公共函数索引(){}}

<小时>

这是无效有效

文件名:Verify_Login.php

class Verify_Login 扩展 CI_Controller {公共函数 __construct() {parent::__construct();}公共函数索引(){}}

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 地址在 html 源代码中的 CodeIgniter http://::1/codeigniter/表单操作中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆