0

我试图更改 $_POST 中字段的值,以便它将为已发布的任何内容加载正确的内容。

当用户访问我的网站时,$_POST 最初设置为

$_POST['order_page_content'] = 'list'

然后,我的 view.content.php 文件中有一个如下所示的表单:

<td><form action='http://localhost/magento_soap_client/fulfilment' method='POST'>
                        <input type='hidden' name='order_page_content' value='info'/>
                        <input type='hidden' name='order_id' value='$order_info->order_id'/>
                        <input type='submit' value='View'/>

                        </form></td></tr>";

因此,当单击按钮时,$_POST['order_page_content'] 的值应更改为 info。因此页面的内容应该改变......

单击按钮后,我可以通过萤火虫看到帖子中的值已更改,只是我的页面没有设置

那么如何根据提交的帖子值进行内容更改?或者出了什么问题?

编辑

好吧,伙计们我试过你说的,但它仍然没有发生,我不知道我是否把它放在错误的地方或者什么......我认为最简单的方法是向你展示我的代码。

决定它是什么内容的脚本在这里: link

调用它的脚本在这里:

public function get_html() {
    $m_html = null;

    if($_POST['order_page_content'] == 'list'){
    $m_obj_html = new content();
    $m_html = $m_obj_html->get_page_content('list');
    }
    else if($_POST['order_page_content'] == 'info'){
        $m_obj_html = new content();
        $m_html = $m_obj_html->get_page_content('info');
    }

    return $m_html;
}

post['order_page_content'] 最初在引导程序中设置为列出

谢谢

4

5 回答 5

0
<input type='hidden' name='order_id' value='<?php echo $order_info->order_id; ?>'/>

如果它已经在 php 中使用

<input type='hidden' name='order_id' value='". $order_info->order_id ."'/>
于 2013-10-25T11:27:52.643 回答
0

$_POST 是从 PHP 全局设置的。

如果您的脚本中有以下内容:

$_POST['order_page_content'] = 'list';

因此,您的变量在每个页面加载时都会被覆盖。在设置之前尝试检查它。

if (!array_key_exists('order_page_content', $_POST)
{
    $_POST['order_page_content'] = 'list';
}
于 2013-10-25T11:28:07.883 回答
0

$_POST 设置为客户端访问站点时发送的发布数据。如果他们发送任何内容,您可以访问它。您的表单看起来应该可以工作。我确实看到的是,您让他们针对本地主机上的页面发送此信息。localhost 是否使用 PHP 运行 apache 或类似服务器?如果是,则在该页面上添加以下内容:

if(!empty($_POST['order_id'])){
    print_r($_POST);
}

如果该表单在您发送到的页面上,并且您希望记住该值(在他们发送表单/发布数据后仍然存在,那么执行以下操作:

<input type='hidden' name='order_id' value='<?php if(!empty($_POST['order_id'])) echo $_POST['order_id']; ?>' />
于 2013-10-25T11:28:47.063 回答
0

似乎问题出在这一行:

<form action='http://localhost/magento_soap_client/fulfilment' method='POST'>

正在执行的 url 正在重置所有内容,所以我现在将其取出并将操作留空并且工作正常

谢谢你们的帮助

于 2013-10-25T14:59:00.430 回答
0

Tom 你可以使用 if 条件来检查它

if($_POST['order_page_content']=="info"){some code} else { some code}
于 2013-10-25T11:26:58.530 回答