Is it possible redirect to a URL with a POST request rather than a GET request? [duplicate]
Possible Duplicate:
Redirect with POST data
Is it possible for a script to redirect to a URL with a POST request in PHP?
The code I currently have uses javascript to submit a form when the body of the page has loaded. I want to avoid this and use a more robust solution if it is possible.
The current code looks like this:
<?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('.', '__开发者_JS百科', $key)) . '"
value="' . htmlentities($value) . '" />';
}
?>
</form>
</body>
</html>
Which is an example from the MCImageManager and MCFileManager file package.
Echoing out the response from a curl request will not work in this instance due to the use of relative file paths in the HTML, which I am unable to easily change.
No, this is not possible.
You have to use Javascript to submit a form or do an AJAX POST.
精彩评论