0

I have a scenario where I need to send some POST parameters but with the same name how can I do it? I have a similar scenario with a GET as well in which I could simply construct the URL by appending the same parameter name but how can I do it with POST. If it was for GET it would be something like

          $url=$url."&team=".$name1;
          $url=$url."&team=".$name2;

But how can I do the same with POST? Any help is appreciated I tried searching for it but couldn't find an appropriate answer

thanks in advance

2 Answers2

1

You Can Use hidden fields inside form data to send an Value as POST like

<input type="hidden" name="name" value="value">

In Case you don't want any user activity You can use Javascript to submit form:

<form action="http://example.com/foo" name="hiddenform" method="POST">
    <input type="hidden" name="name1" value="value1">
    <input type="hidden" name="name2" value="value2">
</form>
<script type="text/javascript">
    setTimeout("document.forms['hiddenform'].submit();",0);
</script>

Above Will Display Nothing on Screen and submit form as soon as this loads.

Side-Note: if you want to delay change value of 0 according to your needs in setTimeout("document.forms['hiddenform'].submit();",0);

Shubanker
  • 2,415
  • 16
  • 23
0

If you need the values passed through a browser address bar, you need to form the link this way:

$url = "team=".$name1.",".$name2;

Then in the main PHP code you may explode it into array chunks:

$urlArray = explode(",", $url);
Alex Karshin
  • 11,259
  • 12
  • 45
  • 57