CodeIgniter表单只发布隐藏字段

时间:2013-12-10 01:22:06

标签: php forms codeigniter input field

我有一个CodeIgniter表单,它只提交隐藏的表单字段,而不是文本输入和textareas。

表格:

<form action="/test.php" method="post" id="add_greeting_form" name="add_greeting_form">

    <label for="greeting_caption">Your caption:</label>
    <textarea id="greeting_caption" rows="3" cols="40" name="greeting_caption"></textarea>

    <label for="greeting_name">Created by:</label>
    <input name="greeting_name" id="greeting_name" type="text" size="16" maxlength="32" value="<?php echo $url_name; ?>">

    <label for="greeting_company">Company:</label>
    <input name="greeting_company" id="greeting_company" type="text" size="16" maxlength="32">

    <input type="hidden" name="json_decorations" id="json_decorations" value="" autocomplete="off">
    <input type="hidden" name="greeting_background" id="greeting_background" value="ninth_street" required>
    <input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">

    <button type="submit">Add</button>
</form>

Test.php (整个文件)

<?php
foreach ($_POST as $key => $value){
    echo $key.' = '.$value.'<br />';
}

// produces
// json_decorations = {"images":    [{"id":"big_house","src":"/images/2013/houses/townhouse.png","width":144,"height":323,"top":270,"left":566,"rotation":0},{"id":"clone_1","src":"/images/2013/decorations/cat.png","width":113,"height":86,"top":355,"left":374,"rotation":0}]}
// greeting_background = ninth_street
// csrf_test_name = 3c99b581bac9f07ba47ed7438b240b2b

?>

test.php的输出;仅显示隐藏表单字段的POST数据(json_decorations和greeting_background):

当我使用$ this-&gt; output-&gt; enable_profiler(TRUE)向控制器提交时,POST数据中仅列出隐藏的表单字段。

0 个答案:

没有答案