2011-08-04 10 views
0

可能性の重複:スクリプトはPHPでPOSTリクエストでURLにリダイレクトするため
Redirect with POST dataGETリクエストではなくPOSTリクエストでURLにリダイレクトできますか?

それは可能ですか?

私が現在持っているコードは、ページの本文がロードされたときにフォームを送信するためにjavascriptを使用しています。私はこれを回避し、可能であればより堅牢なソリューションを使用したいと考えています。 MCImageManagerMCFileManagerファイルパッケージからの一例である

<?php 
// Change this secret key so it matches the one in the imagemanager/filemanager config 
$secretKey = "someSecretKey"; 

// Check here if the user is logged in or not 

if (!isset($_SESSION["some_session"])) 
    die("You are not logged in."); 


// Override any config values here 
$config = array(); 
//$config['filesystem.path'] = 'c:/Inetpub/wwwroot/somepath'; 
//$config['filesystem.rootpath'] = 'c:/Inetpub/wwwroot/somepath'; 
// Generates a unique key of the config values with the secret key 
$key = md5(implode('', array_values($config)) . $secretKey); 
?> 

<html> 
    <body onload="document.forms[0].submit();"> 
     <form method="post" action="<?php echo htmlentities($_GET['return_url']); ?>"> 
      <input type="hidden" name="key" value="<?php echo htmlentities($key); ?>" /> 
      <?php 
      foreach($config as $key => $value) { 
       echo '<input type="hidden" name="' . 
          htmlentities(str_replace('.', '__', $key)) . '" 
          value="' . htmlentities($value) . '" />'; 
      } 
      ?> 
     </form> 
    </body> 
</html> 

現在のコードは次のようになります。

curl要求からの応答をエコーすると、HTML内の相対ファイルパスが使用されるため、この場合はが動作しません。これは簡単には変更できません。

+0

[POSTデータによるリダイレクト](http://stackoverflow.com/questions/6614076/redirect-with-post-data)と[POSTデータによるPHPリダイレクト](http://stackoverflow.com/質問/ 5576619/php-redirect-with-post-data) – deceze

+0

@deceze agreed - 投票を終了する。私は自分の探しているものを見なかった。 – Treffynnon

答えて

1

いいえ、これはできません。

Javascriptを使用してフォームを送信するか、AJAX POSTを実行する必要があります。

関連する問題