site_url将localhost更改为[:: 1] [英] site_url changes localhost to [::1]

查看:341
本文介绍了site_url将localhost更改为[:: 1]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前使用过CodeIgniter,从上次使用以来已经有很长时间了,所以我基本上回到第1步。

I've used CodeIgniter before and it's been quite a long time since I've last used it so I'm basically going back to step 1.

我具有以下代码的控制器CaseCon

I have the controller CaseCon with the following codes

  public function index()
    {
        $this->load->view('CaseView');
    }

  public function sendTicket() {
    echo "This is sendTicket function";
  }

,我的html页面有以下代码

and my html page has the following code

<form method="POST" action="<?php echo site_url('CaseCon/sendTicket');?>">
  <input id="full_name" type="text" class="validate" name="Name" value="Name" />
  <input type="submit" value="Submit" />
</form>

我试图在本地服务器上运行。点击提交按钮后,页面重新加载并将 localhost:8888 更改为 [:: 1] 。我不知道哪一部分,我有一个错误。如果我强制URL到 /index.php/CaseCon/sendTicket

I'm trying to run this on a local server. Upon clicking the submit button, the page reloads and changes the localhost:8888 to [::1]. I'm not sure which part do I have an error. I'm getting the expected output if I force the url to go to /index.php/CaseCon/sendTicket.

请注意。感谢。

推荐答案

我认为您的base_url空白。

I would think You have your base_url blank.

$config['base_url'] = '';

这就是为什么 [:: 1] 您尚未设置您的base_url,但这是会发生的

That is why [::1] You don't have set your base_url but that is what will happen

设置您的基本网址

$config['base_url'] = 'http://localhost/your_project_name/';

$config['config_base_url'] = 'http://localhost:8888/your_project_name/';




注意:您的类和文件名只有第一个字母大写。

Note: Your class and file name only have first letter upper case.

档案名称:Casecon.php

File name: Casecon.php

class Casecon extends CI_Controller {

  public function index() {

  }
}

它可能以localhost的方式工作,但在某些现有的服务器上你会遇到问题。

It might work on localhost the way you have it but on some live servers you will run into issue.

查看表单

<form method="POST" action="<?php echo base_url('casecon/sendTicket');?>">
  <input id="full_name" type="text" class="validate" name="Name" value="Name" />
  <input type="submit" value="Submit" />
</form>

如何创建控制器

如何创建模型

这篇关于site_url将localhost更改为[:: 1]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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