Example form that posts to a page which sends a 307

(don't change values below, just press submit)



Source

This file (index.php)

<html>
<head>
<title>Example form that posts to a page which sends a 307</title>
</head>
<body>

<h2>Example form that posts to a page which sends a 307</h2>
<p>(don't change values below, just press submit)</p>
<form action="target.php?c=3&d=4" method="post">
  <p>
    <input type="text" name="a" value="1" /><br />
    <input type="text" name="b" value="2" /><br />
    <input type="submit" name="submit" value="submit" />
  </p>
</form>

<h2>Source</h2>

<h3>This file (index.php)</h3>
<?php highlight_file('index.php'?>

<h3>Post to file (target.php)</h3>
<?php highlight_file('target.php'?>

<h3>Redirect post/get to file (newTarget.php)</h3>
<?php highlight_file('newTarget.php'?>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>

<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-5611225-1");
pageTracker._trackPageview();
} catch(err) {}
</script>

</body>
</html>

Post to file (target.php)

<?php

header
('HTTP/1.1 307 Moved');
header('Status: 307 Moved');
header('Location: newTarget.php' . ($_SERVER['QUERY_STRING'] ? '?' $_SERVER['QUERY_STRING'] : ''));

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Redirecting</title>
</head>
<body>
    <form action="newTarget.php<?=($_SERVER['QUERY_STRING'] ? '?' $_SERVER['QUERY_STRING'] : '')?>" method="post">
        <? foreach ($_POST as $key => $value) { ?>
            <input type="hidden" name="<?=htmlentities($keyENT_COMPAT'UTF-8')?>" value="<?=htmlentities($valueENT_COMPAT'UTF-8')?>" />
        <? ?>
        <noscript>
            <h3>This page has moved.</h3>
            <p><input type="submit" name="page_has_moved" value="View at new location" /></p>
        </noscript>
        <p style="position: absolute; top: -100px"><input type="submit" name="page_has_moved2" value="" /></p>
    </form>
    <script type="text/javascript">
        document.forms[0].elements.page_has_moved2.click();
    </script>
</body>
</html>

Redirect post/get to file (newTarget.php)

<pre><?php

echo ($_POST['a'] == '1' && $_POST['b'] == '2' && $_GET['c'] == '3' && $_GET['d'] == '4' "***PASS***\n" "***FAIL***\n");

echo 
"\nPOSTED DATA:\n";

print_r(array(
    
'$_POST' => $_POST,
    
'$_GET' => $_GET
));

?></pre>

<p><a href="index.php">retry</a></p>