简体   繁体   English

重定向到 XML 文件并返回到 PHP 页面可能吗?

[英]Redirect to XML file and back to PHP page possible?

I'm currently coding an ID filter, whenever a user submits an ID it will pick out all the orders and filters out all the ID's you DON'T want to see from the XML file.我目前正在编写一个 ID 过滤器,每当用户提交一个 ID 时,它都会挑选出所有订单并从 XML 文件中过滤掉您不想看到的所有 ID。

a little preview - XML一点预览 - XML

<filter><!-- Copy filter-item and put the order-id in as the value to skip it-->
    <filter_item>1138850639</filter_item><filter_item>1138371172</filter_item><filter_item>1137835945</filter_item></filter>
</root>

PHP PHP

if (isset($_POST['load'])) 
{
    

    $orderFilter = $_POST['orderItemFilter'];
    
    $xml = simplexml_load_file("Config.xml");
    $sxe = new SimpleXMLElement($xml->asXML());
    $itemsNode = $sxe->filter;
    $itemsNode->addChild("filter_item", $orderFilter);
    $sxe->asXML("Config.xml");  
}   

Now the problem is that the file itself does contain the ID, but the Config.xml HAS TO BE RUNNED to be able to display the final order page.现在的问题是文件本身确实包含 ID,但必须运行 Config.xml 才能显示最终订单页面。 Is there a way to redirect from an XML file to return to the previous page?有没有办法从 XML 文件重定向返回到上一页?

There are two mentioned to do this.有两个提到这样做。

First you can do this in Javascript.首先,您可以在 Javascript 中执行此操作。

 javascript:history.go(-1)

Second, you can do this in PHP, remember it is not ggood idea to because it will not work on HTTPS and headers can be hijacked and reirect to unwanted pages.其次,您可以在 PHP 中执行此操作,请记住这不是个好主意,因为它在 HTTPS 上不起作用,并且标头可以被劫持并重定向到不需要的页面。

header('Location: ' . $_SERVER['HTTP_REFERER']);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM