以html格式传递隐藏变量

时间:2014-02-03 05:39:53

标签: php html forms hidden

我正在尝试以html格式传递隐藏变量。我设置了一个数据并将其打印出来 稍后在提交表单时,我会收到隐藏变量并打印出来,但确实如此 不打印所有值。您可以在最后检查输出转储。你能告诉我为什么吗?

代码

function xyz() {
    if ( isset ( $_POST ['modified'] ) ) {
        $table_name = $wpdb->prefix . "template";
        $templateData =  $_POST['templateData'] ;
        echo "------After passing-------------------------<br />";
        var_dump( $templateData );
        echo "------------------------------<br />";
    } else {
        $table_name = $wpdb->prefix . "template";
        $result = 'SELECT * FROM '.$table_name.' WHERE id='.$item.';';
        $res = $wpdb->get_row ( $result);
        $temp = $res->data ;
        echo "------Before passing-------------------------<br />";
        var_dump($temp);
        echo "-------------------------------<br />";
        // URL for form submit, equals our current page
        $action_url = $_SERVER ['REQUEST_URI'];
        include_once ('template.html');
    }
}

在文件template.html中,我传递了一个隐藏变量$ templateData

<form action="<?php echo $action_url?>" method="post">
    <input type="hidden" name="submitted" value="1" />
    <?php
        echo '<input type="hidden" name="templateData" value="'.$temp.'">';
    ?>

输出:

在通过之前:

  

string(281)“a:21:{i:1; s:1:”2“; i:2; s:1:”1“; i:3; s:2:”12“; i :4; S:1: “1”; I:5; S:1: “1”; I:6; S:1: “1”; I:7; S:3: “A43”; I:8 ; S:0: “”; I:9; S:0: “”; I:10; S:0: “”; I:11; S:5: “标题”; I:12; S:1: “1”; I:13; S:2: “12”; I:14; S:1: “1”; I:15; S:1: “1”; I:16; S:1:“1 “; I:17; S:3:” A23 “; I:18; S:0:” “; I:19; S:0:” “; I:20; S:0:”“; I:21 ; s:7:“摘录”;}“

通过后:

  

string(14)“a:21:{i:1; s:1:”

0 个答案:

没有答案