【问题标题】:how to redirect a page from flash using php如何使用php从flash重定向页面
【发布时间】:2012-09-05 00:07:06
【问题描述】:

大家好,我有以下场景。

我有一个带有按钮的 swf,可以将 URL 请求发送到 php 文件。以下是哪个。

    <?php
      session_start();

      if(isset($_SESSION['user'])){

        header ('Location: http://mydomain.com/test/reroute.php');
        exit();
      }
   ?>

但是,php 文件不会重新路由到所需的页面。我错过了什么吗?

非常感谢,

【问题讨论】:

  • $_SESSION['user'] 是如何设置的?
  • 我觉得不错。也许$_SESSION['user'] 没有设置?您可以通过var_dump($_SESSION) 来查看 $_SESSION 中的内容。
  • 你能展示一些你的actionscript吗?问题似乎是actionscript没有遵循重定向或者php没有正确发送重定向?
  • 直接从浏览器打开php文件是否重定向正确?
  • 来自 Flash 的 URL 请求不会重定向(=更改 URL)页面,SWF 被嵌入其中,无需进一步编码。您将需要使用 JS 工具

标签: php flash web-applications


【解决方案1】:

要从 Flash 转到某个页面,您需要执行以下操作 navigateToURL

navigateToURL(new URLRequest("http://mydomain.com/test/reroute.php"), "_self");

编辑 要对重定向 url 进行软编码,我建议您这样做(我怀疑这与您要查找的内容更相关)

private var loader:URLLoader=new URLLoader();

private function init():void {
    //In the class initialize handler
    loader.addEventListener(Event.COMPLETE, redirectReceived);
}

private function redirectReceived(e:Event):void {
    if(StringUtil.trim(e.target.data).length > 0) {
        navigateToURL(new URLRequest(e.target.data), "_self");
    }
}

private function buttonClick(e:MouseEvent):void {
    loader.load(new URLRequest("http://path_to_the_php_which_tells_you_where_to_redirect"));
}

告诉你重定向到哪里的php是这样的:

<?php
      session_start();

      if(isset($_SESSION['user'])){

        echo('Location: http://mydomain.com/test/reroute.php');

      }
?>

【讨论】:

  • 不错的解决方案。非常感谢您的意见。
猜你喜欢
  • 2011-02-22
  • 2010-10-07
  • 2013-11-13
  • 1970-01-01
  • 2012-12-30
  • 1970-01-01
  • 1970-01-01
  • 2013-06-12
  • 2016-09-16
相关资源
最近更新 更多