php curl将数据从一个iframe发送到另一个iframe

时间:2012-02-20 10:31:07

标签: php iframe curl

我需要使用cURL将数据从一个iframe发送到另一个iframe。我的代码是:

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>New Web Project</title>
    </head>
    <body>
        <form action="postback.php" method="POST">
            <input type="hidden" name="variable" value="send"/>
            <input type="submit" />
        </form>
        <iframe name="test" src="postback.php" width="200" height="200"></iframe>postback
        <iframe name="test2" src="replay.php" width="200" height="200"></iframe>replay
    </body> 
</html>

和两个iframe代码: 回发iframe:

<?php
if (isset($_POST["variable"])){
    $var1 = $_POST["variable"];

        $url = 'http://localhost/xss/replay.php';
        $ch = curl_init($url);
        $parameters = 'variable2='.$var1;
        //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
        curl_exec($ch);
        curl_close($ch);

}
else echo 'w8';
?>

重播iframe:

<?php
if (isset($_POST["variable2"])){
    $var1 = $_POST["variable2"];

    echo $var1;
}
else echo 'w8';
?>

在这种情况下,我得到了来自secound iframe(replay.php)到新页面的响应,而不是打印变量2到secound iframe。我该怎么改变它?我想补充一点,我不能使用JavaScript / AJAX / jQuery等。只有服务器端脚本

1 个答案:

答案 0 :(得分:0)

您可能最好使用javaScript将表单提交到iFrame,而不是使用此服务器端,可以通过将iframe src更改为postback.php?variable = send并使用$ _GET [''来轻松完成]服务器端的参数。

我认为你不能用curl实现你想要的东西

相关问题