Skip to content

Instantly share code, notes, and snippets.

@alvarow
Created March 3, 2016 15:12
Show Gist options
  • Save alvarow/ad91b2d5daae0896fed2 to your computer and use it in GitHub Desktop.
Save alvarow/ad91b2d5daae0896fed2 to your computer and use it in GitHub Desktop.
HTTP POST Preservation in PHP
<?php
echo '<html><body>';
?>
<script>
function submitForm() {
oCombo = document.getElementById('idURLCombo');
oForm = document.getElementById('idMainForm');
oForm.action = oCombo.value;
oForm.submit();
}
</script>
<?php
// Opening form to allow to send the data
echo '<form id="idMainForm" method="POST" action="https://commonag.dit.com/public/twe/dit/">' . "\r\n";
// Storing received POST variables
if (is_array($_POST)) {
foreach ($_POST as $sKey => $sValue) {
echo '<input type="hidden" name="' . $sKey . '" value="' . $sValue .'">' . "\r\n";
}
}
// Combo output
echo 'Select an environment to submit: ';
echo '<select id="idURLCombo" onchange="submitForm();">' . "\r\n";
echo '<option value="https://commonag.dit.com/public/twe/dit/">url 1 (dit)</option>' . "\r\n";
echo '<option value="https://commonag.dit.com/public/twe/fit/">url 2 (fit)</option>' . "\r\n";
echo '<option value="https://commonag.dit.com/public/twe/stg/">url 3 (stg)</option>' . "\r\n";
echo '</select>' . "\r\n";
echo '</form>' . "\r\n";
echo '</body></html>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment