dongqiang1226 2014-03-26 09:19
浏览 49

从PHP中的eval()函数提交表单POST数据

I get some values from a mySQL table into an array and then loop through the array, using an eval function to declare functions named after the values from the table. Inside these functions there is some code that creates a html form. Even though the form method is set to POST, the form input names and their values then appear in the URL like GET data.

<?php
$tables = $wpdb->get_results('select distinct form from forms', ARRAY_A);
for ($i=0;$i<count($tables);$i++) {
    $a[] = $tables[$i][form];
}

foreach ($a as $functionname) {
    if (!function_exists($functionname.'_list')) {
        eval('function '.$functionname.'_list() {
        global $wpdb;
        $page = the_permalink();
        echo "<form mehtod=\"POST\" action= \"".$page."\">";

        // I loop through this a few times populating the form with more data from a DB table

        echo "<div id = \"mySQLwp_form_row\">
                 <div id = \"mySQLwp_form_cell_left\">
                     <input type = \"checkbox\" name=\"fields\" value =\"".$fields[$i][label]."\">
                 </div>
                 <div id = \"mySQLwp_form_cell_right\">".$fields[$i][label]."</div>            </div>";

        echo "<br><input type=\"submit\" class=\"button-primary\" value=\"submit\" style = \"float:left\">
        </form>";


        }');

    }
}
?>

This is what the URL looks like after pressing submit:

http://mydomain.com.au/wp-admin/admin.php?fields=Enquiry+Date&fields=Parent%27s+last+name&fields=Child%27s+last+name&fields=Requested+care+days&page=bilby_bo_enquiry&tab=list

How can I get my eval() function to render a html form that posts instead of sending values in the URL?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 聚类分析或者python进行数据分析
    • ¥15 逻辑谓词和消解原理的运用
    • ¥15 三菱伺服电机按启动按钮有使能但不动作
    • ¥15 js,页面2返回页面1时定位进入的设备
    • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
    • ¥15 错误 LNK2001 无法解析的外部符号