输出与服务器提供的URL相同的URL的程序(PHP,JSON)

I am not a programmer so please bear with me.

I created a simple form that will ask for an "ID" and "Links". When I click submit it will display the URL on the second form.

For example I input 12345 in the "ID" and https://www.example1.com in "Links".

The output.php form has this code:

<script>document.write(window.location);
</script></br>

The result using my program is:

API/output.php?id=12345&links=https%3A%2F%2Fwww.example1.com

I want the program result to be like this:

API/12345.json?blast%5Blinks%5D=https%3A%2F%2Fwww.example1.com

Which means that since I input 12345 in the "ID" field, I want to show the result as 12345.json(plus the link) and not output.php(plus the link)

How can I do this?

If I understand your problem, you have a form that takes id and link fields, and your result should be API/id.json?blast[links]=link (where id and link come from your form), properly URL encoded.

Try this:

<?php

  if($_SERVER['REQUEST_METHOD'] == 'POST') {
      $url = $_POST['link'];
      $id = $_POST['id'];
      print 'API/'$id.'.json?blast'.urlencode('[links]='.$url);
  }

?>