而不是Form动作和方法

use*_*187 6 php codeigniter

<?php echo validation_errors(); ?>

<?php echo form_open('form'); ?>
    <input type="text" name="something" />
    <input type="submit" value="submit"/>
</form>
Run Code Online (Sandbox Code Playgroud)

我发现没有"行动"和"方法"

<form action="/application/controler/somepage.php" method="POST">
</form>
Run Code Online (Sandbox Code Playgroud)

在按下提交按钮后,我想在文本框中输入值.我怎样才能像前者一样(通过POST或GET获取值)?

另外,如果我想获取URL中传递的值 http://localhost/index.php/something?value=75&today=Wed

75Wed,例如.

Tou*_*hid 17

试试这个:

echo form_open('controller/somepage', array('method'=>'get'));
Run Code Online (Sandbox Code Playgroud)

  • 通过在它之前添加4个空格或将它放在``字符之间来缩进代码. (2认同)

Jor*_*eno 6

CodeIgniter的表单辅助文档指出,你的手到的第一个参数form_open()的功能是您要发布帖子的网址.URL语义是CodeIgniter的重要组成部分,如果您要发布到应用程序内的某个位置,请使用:

<?= form_open('index.php/controller/function/param1/param2');?>
Run Code Online (Sandbox Code Playgroud)

CodeIgniter method='post'默认使用.

CodeIgniter本身不支持form method='get'参数,因为它处理URL的方式.而不是URL:

http://localhost/myapp/index.php/something?value=75&today=Wed
Run Code Online (Sandbox Code Playgroud)

CodeIgniter的方式是:

http://localhost/myapp/index.php/mycontroller/myfunction/75/Wed
Run Code Online (Sandbox Code Playgroud)

然后,您将在控制器中定义一个函数

function myfunction($value, $day)
{
//do whatever you want with the $value and the $day here.
}
Run Code Online (Sandbox Code Playgroud)