Created
June 9, 2022 02:46
-
-
Save fadlisaad/9ee278918369a09f6552e47365d5853e to your computer and use it in GitHub Desktop.
Laravel manual redirect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function render($data) | |
{ | |
$url = 'https://melakapaystg.melaka.gov.my/stom/request'; | |
echo "<form id='autosubmit' action='".$url."' method='post'>"; | |
if (is_array($fieldValues) || is_object($fieldValues)) | |
{ | |
foreach ($fieldValues as $key => $val) | |
{ | |
echo "<input type='hidden' name='".$key."' value='".htmlspecialchars($val)."'>"; | |
} | |
} | |
echo "</form>"; | |
echo "<script type='text/javascript'> | |
function submitForm() { | |
document.getElementById('autosubmit').submit(); | |
} | |
window.onload = submitForm; | |
</script>"; | |
} | |
// Sample usage | |
$data = [ | |
'merchant-code' => 'stom', | |
'amount' => '100' | |
]; | |
return $this->render($data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment