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


Program that outputs URL same with what is provided by the server(PHP,JSON)

我不是一个程序员,所以请原谅我。

我创建了一个简单的表单,将要求"ID"answers"链接"。当我点击提交时,它会在第二个表单上显示URL。

例如,我在"ID"中输入12345,在"Links"中输入https://www.example1.com。

output.php表单的代码如下:
<script>document.write(window.location);
</script></br>
使用我的程序的结果是:

API/output.php ? id = 12345,链接3 = https % % 2 f % 2 fwww.example1.com

我希望程序的结果是这样的:

12345. API/json ?爆炸% 5眨眼% 5 d = https % % 2 f % 2 3 fwww.example1.com

这意味着,由于我在"ID"字段中输入了12345,因此我希望将结果显示为12345。Json(加链接)而不是output.php(加链接)

我该怎么做?

如果我理解你的问题,你有一个需要idlink字段的表单,你的结果应该是API/id.json?blast[links]=link(其中idlink来自你的表单),正确的URL编码。

试试这个:

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