发布 link 信息 PHP

POSTing link information PHP

所以,显然,我不能使用 <a> 将 PHP POST 请求发送到另一个页面。我在某处读到(我想在这里),我可以使用适当的 CSS 表单提交按钮来假装某个东西是 link 然后 POST,但是我'我不知道该怎么做——到目前为止我发现的所有方法都仅限于发送按钮的 'value' 参数(AFAIK 是它的标签),但我想发送 other 信息比那个。

我该如何实现?

您可以使用隐藏的输入来做到这一点。即输入类型="hidden"。在表单操作中,您需要放置需要提交的 url。

至于使提交看起来像 link,您需要使用一些 CSS

css

input[type="button"], input[type="button"]:focus, input[type="button"]:active,  
button, button:focus, button:active {
/* Remove all decorations to look like normal text */
background: none;
border: none;
display: inline;
font: inherit;
margin: 0;
padding: 0;
outline: none;
outline-offset: 0;
/* Additional styles to look like a link */
color: blue;
cursor: pointer;
text-decoration: underline;
}

html

<form action="#" method="post">
  <input type = "hidden" name = "foo" value = "foo">
  <input type = "hidden" name = "bar" value = "bar">
  <button type = "submit">Click me!</button>
</form>

Codepen Demo