我想将变量(id)和表单数据传递给控制器函数。代码如下:
<form action = "index.php/my_controller/my_function" method = "POST">
<input name = "comment" type = "text" size = "8">
<input type = "submit" value = "save">
</form>
<?php
my_function($id){
// get the text
// get the id
//save id and text
}
?>
当我尝试
时`action = "index.php/my_controller/my_function/<?php echo record['ID']?>"`
其中$ record ['id']给我id,URL显示id,但是我如何将它传递给控制器文件中的my_function($ id)。
答案 0 :(得分:2)
尝试使用隐藏字段
<form action = "index.php/my_controller/my_function" method = "POST">
<input name = "id" type = "hidden" value="<?php echo $id; ?>">
<input name = "comment" type = "text" size = "8">
<input type = "submit" value = "save">
</form>