Skip to content

Instantly share code, notes, and snippets.

@yphastos
Last active November 9, 2020 13:57
Show Gist options
  • Save yphastos/a1809b654de9702811d3a09a66cf82a3 to your computer and use it in GitHub Desktop.
Save yphastos/a1809b654de9702811d3a09a66cf82a3 to your computer and use it in GitHub Desktop.
PHP - Redirect with POST data
public static function redirect_post($url,$params){
$html = "";
$html.= '<!doctype html>
<html>
<head>
<script type="text/javascript" language="JavaScript" src="lib/js/jquery-1.8.3.js"></script>
<script>
$(function(){
$("#redirect_form").submit();
});
</script>
</head>
<body>
<form id="redirect_form" method="post" action="'.$url.'" >
';
foreach($params as $k => $v){
$html.= "<input type='hidden' name='$k' id='$k' value='$v' />";
}
$html.= "
</form>
</body>
</html>";
echo $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment