0

This is my code:

$gateway = "http://html.net/page.php?name=Joe";

<form action="<?php echo $gateway ?>" method="LINK" target="_blank">
<input type="submit" value="Open link"> </input></form>

However, when the link is open, the URL brings me to http://html.net/page.php only. How can I make it bring me to that gateway link?

CHAN HAU YEEN
  • 343
  • 2
  • 5
  • 18

1 Answers1

0

You have to specifically encode your GET variables in as hidden form fields.

<?php
$gateway = 'http://html.net/page.php?name=Joe';
$parsedUrl = parse_url($gateway);
$query = $parsedUrl['query'];
parse_str($query, $parsedQuery);
?>
<form action="<?= $gateway ?>" method="get" target="_blank">
    <div>
<?php
foreach ($parsedQuery as $key => $value) {
?>
        <input type="hidden" name="<?= $key ?>" value="<?= $value ?>" />
<?php
}
?>
        <input type="submit" />
    </div>
</form>
John Kurlak
  • 6,594
  • 7
  • 43
  • 59